Let’s say we have a test.cpp as follows:
class A;
class B
{
private:
A mutable& _a;
};
Compilation:
$> gcc test.cpp
test.cpp:6:20: error: reference ‘_a’ cannot be declared ‘mutable’ [-fpermissive]
My gcc:
$> gcc --version
gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Why?
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: