Quote:Original post by FrunyQuote:Original post by ApochPiQ
This can also be done with aliasing, where multiple pointers/references point to a single object:void SomeObject::ConstFunction(SomeObject& nonconstobj) const{ nonconstobj.member = value;}SomeObject foo;foo.ConstFunction(foo);
That's not really getting around anything, since you still need a non-const reference. The fact that you have a const member function, or even the fact that you have a member function at all is barely relevant. Except for accessing private members, I guess.
If I were to just give you a const Foo&, you'd be stuck.
This is true - but as long as a non-const Foo& is available somewhere, aliasing can still bypass constness to some extent. Yeah, the example's not so great, but I couldn't think of one that looks real-worldish and wasn't excessively long.