const correctness - should C++ prefer const member over non-const?

const correctness - should C++ prefer const member over non-const?

Post by anon » Fri, 31 Oct 2008 18:42:49



Because your myFoo object is not const
 
 
 

const correctness - should C++ prefer const member over non-const?

Post by Martin Eis » Fri, 31 Oct 2008 21:50:38


Then either the two methods' semantics are too different for a
single identifier, or the entity making the offending calls shouldn't
get its hands on a non-const reference, or you should memoize the
rebuilding method.


Martin

--
Quidquid latine scriptum est, altum videtur.

 
 
 

const correctness - should C++ prefer const member over non-const?

Post by Hendrik Sc » Sat, 01 Nov 2008 22:55:15


While I do remember this feeling, this case is rather simple:
You modify 'const', so a 'const_cast' would be what you should
use.


Schobi