Quote:
As to a solution, the classes are not const-correct, so there's no point in trying to declare the pointer const - it gives no guarantees if you are looking for ways to get round const-correctness at the same time. (As they say, const is a "virus", it needs to propagate to all parts of the code if you want to use it properly. You can't make some parts of the code const-correct and other parts not.)
The point about mutable is that it allows innocuous changes to be made to objects which are otherwise const. Of course, it's debatable what is innocuous at design time, but at compile time it's defined. So a const pointer does give a guarantee: that members not declared mutable won't be changed.
Quote:
Or, instead of inheriting, make A a mutable member of B (but again, there should be some justification for that).
Yes, I agree on both counts. I assume by 'justification' you mean something more conceptual than just my search for const-safety? It's someone else's code which I'm relunctant to tamper with but I think they were probably right to use inheritance - hence my wish to *inherit* mutably.