Re: Const'ness


Subject: Re: Const'ness
From: Martin Sevior (msevior@mccubbin.ph.unimelb.edu.au)
Date: Fri Jul 07 2000 - 19:27:55 CDT


On Fri, 7 Jul 2000, Thomas Fletcher wrote:
>
> Well I profess to be no expert, but in general if
> you are returning a const pointer you are indicating
> to the calling program that they can't do any modification
> of the data that this pointer points to. This allows
> the compiler to do some extra optimization, along with
> enforcing better programming habits (which is why we
> are catching there errors when we mess something
> up.
>

Ah this makes sense. I can't modify the contents of a const pointer. I
never do anyway since that goes againt spirit protected member variables.
If something needs changing I always use a setForVariable function.

> The most excellent reference that I can point you to
> is the Stroustrop book section 5.4 which discusses
> all sorts of differences between const's and the
> ramifications of each.
>
> The main worry that I have with casting away const
> is that the const behaviour might have been counted
> on at some point by a higher level app.
>

No problem. I know where that code is used and we never do anything so
bad.

Cheers

Martin



This archive was generated by hypermail 2b25 : Fri Jul 07 2000 - 19:28:07 CDT