The ampersand in front of &top->topval(...)
returns the address of the object returned from topval
. This is because the member access operator ->
has higher precedence than the address-of operator. So when we assume that Stock::topval
returns a reference to another Stock
object, we can get the address of that one and bind it to Stock *top
.
0
solved C++ primer plus list:10.9 The “top” pointer problem