[prog] C++ const method & static_cast
Karine Proot
kproot at nerim.net
Mon Mar 22 23:31:07 EST 2004
On Mon, 2004-03-22 at 08:51, Dan Richter wrote:
> The second potential problem is that if getPrevious() is const, then any
> pointer to a member that it returns must be const.
> [...]
> The const is strongly enforced in C++. If you are going to return a
> pointer to a member from a const method, it has to be const.
That was it. Thanks for the detailed explanation.
> One more thing: this strong enforcement of the const in C++ means that
> you'll find it quite a pain to add it to an already complete program.
Indeed. I tried to use
const Tab *getPrevious() const;
and I got a full delivery of
invalid conversion from `const Tab*' to `Tab*'
Now is the time to ask myself if it's worth it :)
Thanks again
Karine
More information about the Programming
mailing list