Another way to tie a pointer to an object is to use the
address-of operator, &
, which obtains the address of an
object in memory. For example, if c
is an object of type
cylinder
, then the value of the expression &c
is the address
of that cylinder
object, and, inasmuch as the value of &c
is a
cylinder
object's address, you can assign that value to a cylinder
pointer:
cptr = &c;
The address-of operator is not used as much in C++ as in C, because C++'s reference parameter feature, introduced in the hardcopy version of this book, reduces the need to pass pointers as function arguments.