If there is const at the end of a method declaration in C++, it means you can not change any member data. Because this pointer would be const. Is there something like in Java? If not, any similar way to prevent alteration of data member?
#include <iostream>
class MyClass
{
private:
int value_;
public:
void Foo() const
{
value_ = 123;
}
};
Probably the error message occurs, assignment of member 'MyClass::value_' in read-only object