[LC++]How to use const member functions correctly?

Carlo Wood carlo at alinoe.com
Sat Sep 22 11:28:04 UTC 2001


On Fri, Sep 21, 2001 at 09:22:36PM +0200, Davide Bolcioni wrote:
>    c1.f(c1); // Sets c1.n to 3 ... oops, const changed.

No oops imho, 'c1' changed - which is ok because 'c1' was NOT constant.
If you'd try:

C const c1;
...
c1.f(c1);

then the compiler would complain.  So the code is perfectly safe.

-- 
Carlo Wood <carlo at alinoe.com>



More information about the tuxCPProgramming mailing list