|
A pointer is a memory address. Working with pointers requires drawing pointer diagrams. Do not try to keep pointer diagrams in your head.
&x | The address of x. |
*p | The variable that p points to. |
*(&x) | The same as x. |
p = q | Make p point to the place where q points. |
*p = *q | Copy the value of the variable that q points to into the variable that p points to. |
T *p; | p has type T* if and only if *p has type T. |
type of &x | If x has type T then &x has type T*. |
Declaration
const double* q = ptr;
means that you cannot use q to change
what is stored in variable *q.
But you can change the memory address
that is stored in q.
|