|
-
Sep 20th, 2000, 08:50 AM
#1
Thread Starter
Member
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
-
Sep 20th, 2000, 11:48 AM
#2
Lively Member
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...
-
Sep 20th, 2000, 11:59 AM
#3
Thread Starter
Member
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,
-
Sep 20th, 2000, 01:01 PM
#4
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 21st, 2000, 02:35 AM
#5
Thread Starter
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|