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
----- Original Message -----
From: Richard Hartman <[EMAIL PROTECTED]>
Newsgroups: palm-dev-forum
To: Palm Developer Forum <[EMAIL PROTECTED]>
Sent: Tuesday, March 28, 2000 12:01 PM
Subject: Re: Concept questions
>
> Ok, I'm going to risk looking stupid here, but I am fairly sure
> that "const char *" is a declaration for a pointer to constant
> chars, not a constant pointer to (changable) chars. "const"
> is one of those really tricky keywords, but I think it modifies
> the closest object. Thus:
>
> const char *p; // pointer to const char data
> char const *p; // const pointer to char data
> const char const *p; // const pointer to const char data
>
> and I -think- you can even do
>
> char * const p; // another way to say const pointer to char
> data
>
> [flip, flip flip]
>
> Yes, in the Stroustroup book, he shows
>
> const char * (ptr to const char)
> and
> char * const (const ptr to char)
>
> but does -not- discuss
> char const *
> oddly enough. (I still say that's another wayto say const ptr to char)
>
>
> And yes, if you plan on changing the LastName data, that
> would be a silly way to declare it.
>
>
> --
> -Richard M. Hartman
> [EMAIL PROTECTED]
>
> 186,000 mi/sec: not just a good idea, it's the LAW!
>
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html