The essence of the const keyword is that it makes the implicit this parameter const, so a const object can be passed as well as a non-const.
Like
Code:
void func(int *);
void func2(const int *);
const int ci = 3;
int i = 4;
func2(&i); // Yes, non-const -> const
func2(&ci); // Yes, const -> const
func(&i); // Yes, non-const -> non-const
func(&ci); // No, const -> non-const
So, if you explicitly write out the this parameter to methods (which you may not do in real code of course):
Code:
class c {
public:
void method(); // void method(c *this);
void method2() const; //void method2(const c *this);
};
c o;
const c co;
o.method(); // method(&o); Yes
o.method2(); // method2(&o); Yes
co.method2(); // method2(&co); Yes
co.method(); // method(&co); No
The const keyword essentially does this.
The mutable keyword makes members modifiable through const pointers.