The first const means what it returns is a pointer to const A. So no, you can't change what it returns (unless you cast away the const-ness, which will give undefined behavior if the object it returns is actually defined as const
, rather than returning a const
pointer to an object that itself wasn't defined as const
).
The second const means that get_value
can't change any of the (non-mutable) state of the ClassB
on which it's invoked (among other things, it's transitive, so ClassB::get_value
can only call other member functions that are also const
-qualified).