Let\'s say we have a test.cpp
as follows:
class A;
class B
{
private:
A mutable& _a;
};
Compilation:
There is no reason to have a reference member mutable. Why? Because const member functions can change the object which is referenced by a class member:
class B {
public:
B(int var) : n(var) {};
void Set(int val) const { n = val; } //no error
void SetMember(int val) const { m = val; } //error assignment of member `B::m' in read-only structure
protected:
int& n;
int m;
};