I'm working on a matrix class in C++ and have overloaded the parentheses () operator to provide me with element-level access to the matrix elements. I have two overloaded operators like this: one for read-only access to the elements, and one to modify.
However I'm confused as to why the program is using the modifying version instead of the read-only version when I'm simply accessing the element.
I've attached the source to a very-stripped down class along with a test program. I would expect the output to be
but instead I get 3 "Modify"s. Perhaps someone can explain to me why this is, and how I can fix it?Code:Modify Access Access
I should also note that I've tried the accessor function with a const in front of it, thusly:
but I still get the same results.Code:const double operator()(int, int) const;
Bookmarks