How do I define a constant in C++, that points to a mutable object?
If I declare
static const CMyClass* IMPL;
and assign
const CMyClass* CSomeClass::IMPL = new CMyClass;
then I can only call const
functions on the object. Its internals are locked. This is not what I want.
If I leave off the const
qualifier, I can reassign the pointer IMPL
, so it isn’t protected as a constant anymore, which it should be. final
seems to be applicable only to functions in C++. Is there an equivalent to a Java’s final
variables in C++?