I was wondering how protect a non const pointer member from an object throught a const method. For example:
class B{ public: B(){ thi
If you change the member of A from
A
B* b;
to
B b;
then you will get the expected behavior.
class A{ public: A() : b() {} void changeMemberFromConstMethod() const{ this->b.setVal(); // This will produce a compiler error. } private: B b; }