Brandon Wallace wrote in message <6387@palm-dev-forum>...
>
>Close, but not quite right...
>
>The easy way to remember 'const' is it always modifies
>the thing to the LEFT of it. And if there is nothing to
>the left, then it modifies the thing to the right.
>
>const char *p; // pointer to const char
>char const *p; // look to the left...pointer to const char
>char * const p; // look to the left...const pointer to modifiable char
>const char * const p; // const pointer to const char
>char const * const p; // const pointer to const char
>const char const * p; // haven't checked, but compiler should generate an
>error here.
>
>
>Run these through the compiler if you do not believe me.
>brandon
So has this been changed since the Stroustroup book
was published? What he says (sec. 8.2.1, p133 in my
edition) is:
When a const of volatile type specifier appears in
a declaration it modifies the immediately following declarator...
That is to say, the item to the -right- of the "const".
Of course, as I said before, the only examples he gives
avoid the case with the "const" in the middle (char const *),
but given his statement it looks like it should make the ptr
const, not the chars being pointed at.
Now I haven't yet run these through my compiler, but
maybe I will ....
Regardless, the original respondant was wrong
about const char *.
-rmh
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html