Program Notes
In most contexts, C++ interprets the name of an array as the address of its first element. Thus, the following statement makes pw
a pointer to type double
and then initializes pw
to wages
, which is the address of the first element of the wages
array:
double * pw = wages;
For wages
, as with any array, we have the following equality:
wages = &wages[0] = address of first element of array
Just to show that this is no jive, the program explicitly uses the address operator in the expression &stacks[0]
to initialize the ps
pointer to the first element of the stacks array.
Next, the program inspects the values of pw
and *pw
. The first is an address, and the second is the value at that address. Because pw
points to the first element, the ...
Get C++ Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.