const ptr to const ptr ?

F

franco ziade

is that permitted? int const*const* p;

what does it mean ? meaning both pointers can only look at a constant
location and the value of the int can only change? this means no array?

Thanks
 
J

Jarmo

franco ziade said:
is that permitted? int const*const* p;

My guess is that you will never see this in practice. And if you do, head
over to that guy's cubicle with a big stick ;-)
 
C

Clark S. Cox III

is that permitted? int const*const* p;

what does it mean ?


Start from the right:

p
*p ...is a pointer
const *p ...to a constant
*const *p ...pointer
const *const *p ... to a constant
int const *const *p ... int

So, altogether: "p is a pointer to a constant pointer to a constant int"


meaning both pointers can only look at a constant
location and the value of the int can only change?

(p) is not constant (i.e. you can change what p points to)
(*p) is constant (i.e. you cannot change what *p points to)
(**p) is a constant int (you cannot change its value)
this means no array?

No, it could very well be a pointer to an array of pointers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top