yes... pointers can made const. The compiler will tell you if you attempt to change const pointer, which adds a great deal of safety.
When using const with pointers, you have two options : const can be applied to what the pointer is pointing to, or the const can be applied to the address stored in the pointer itself.
2007-02-11 17:51:23
·
answer #1
·
answered by Rishi 3
·
1⤊
0⤋
Yes pointers can be made const pointers as well.
const char *const cpc
is a definition to declare a const character pointer.
Of course, there are special initialization and assignment rules that one needs to follow for these const pointers to work. I would suggest referring to Stroustrup/Lippman for further details
int *const pci
is a definition to declare a const integer pointer where the content of the pointer can be modified, but the pointer itself can't.
2007-02-12 05:04:19
·
answer #2
·
answered by justinageneralway 3
·
1⤊
0⤋
Yes, a pointer can be const.
2007-02-12 03:12:12
·
answer #3
·
answered by rivalslayer 1
·
0⤊
0⤋
Yes pointers can be made const..
Src:
http://www.cprogramming.com/tutorial/const_correctness.html
2007-02-12 02:15:15
·
answer #4
·
answered by Neo was Here 3
·
0⤊
0⤋
yes of course it can be made a constant and there will be an error if u try to change that thing
2007-02-12 04:18:53
·
answer #5
·
answered by sweetboy 3
·
0⤊
0⤋