For the parameter
int const * num // num is a pointer to const int.
const is protecting the num
points to.The program can alter the value of num
but not *num
. While for
int const * const num // num is a const pointer to const int
leftmost const
is protecting the num
points to while right most is protecting pointer num
it self. In this case neither num
nor *num
is going to modify.
NOTE: Understanding what does
T const *p; // T is any valid type
means (more precisely).
This means that, a program can use the expression p
to alter the value of the pointer object that p
designates, but it can’t use the expression *p
to alter the value of any objects that *p
might designate. If the program has another expression e
of unqualified type that designates an object that *p
also designates,the program can still use e
to change that object.