hi, Im tryin to overload the () operator for arrays operations.
to create a rvalue
to use like
Code:
int main()
{
//this is not a const object so why i need a const member fucntion?
Array a1(5,5);
cout << a1(1,2) //print element 1,2 .
}
I need to declare the function that way:
Code:
const int &MyClass::operator()(int,int)const.
why I need to make this function const??(I mean the last const)
please any clear explanation why should i do this that way?
if i dont write the last const the compiler generates an error message.
thanks for any help