Brian K. Smith wrote in message <6344@palm-dev-forum>...
>
>
>>
>>   const char            *LastName;
>>
>> Stupid question, but why would you want to use const if you plan on
chaning
>> the data?  Because I am using multiple forms to display the data for each
>> record, I have made a global person record to store the record being
edited.
>> I have a function that copies the field data to the record and the record
>> data to the fields when the user switches forms.
>
>Here your telling the compilar that the address where the data is stored
>is constant or in other words your not dynamically allocating the memory
>for LastName and thus changing the pointer. The data at the address that
>LastName points to can change, the address can't.

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

Reply via email to