8. new
is not the only option
To use a pointer, you don't always have to perform a new
In addition to new
, a pointer can be given a value using the &
operator, or by assigning it the value of another pointer.
Think and test:
- What's the difference between
p
and r
in following examples?
int *p, q = 10, *r;
p = &q;
r = p;