Click to See Complete Forum and Search --> : Question in C++??
Wesam
Sep 20th, 2000, 08:50 AM
Hi everybody,
My question is: What is the difference between these two statements const char* p and char* const p ?
I appreciate your help,
Wesam
Blitz
Sep 20th, 2000, 11:48 AM
const char* p
is a pointer to a constant char. The value that is pointed to can't be change.
char* const p
is a constant pointer to a char. The char can be change but it can't point to anything else.
Hope this helps...
Wesam
Sep 20th, 2000, 11:59 AM
Thank you, it helped; but may I ask another question in the same context: what is the advantage of declaring a pointer to a constant char for example where we can't change the value of that char and where we can set the pointer to point to different thing??
Wesam,
parksie
Sep 20th, 2000, 01:01 PM
If you have a char* variable as a member of your class. You supply a const pointer, so that they can change the pointer, but are not allowed to change the string inside your class.
Wesam
Sep 21st, 2000, 02:35 AM
Thank you,
Wesam
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.