EXAMPLE The following pair of declarations demonstrates the difference between a ‘‘variable pointer
to a constant value’’ and a ‘‘constant pointer to a variable value’’.
1 2
| const int *ptr_to_constant;
int *const constant_ptr; |
The contents of any object pointed to by ptr_to_constant shall not be modified through that pointer,
but ptr_to_constant itself may be changed to point to another object. Similarly, the contents of the
int pointed to by constant_ptr may be modified, but constant_ptr itself shall always point to the
same location.
Partager