![]() |
![]() |
![]() |
![]() |
![]() |
|
In particular, if you arrange for the railroad_car parameter,
r, to be a call-by-reference parameter, the entire box_car
object is visible to the C++ mechanism that determines which
capacity virtual member function to use:
Memory reserved for Memory for box_car argument railroad_car parameter | | | *--------------------------------------* | | v v *-----* | | | |-----| | | | | |-----| | Entire object is visible | | | |-----| | | | | |-----| | | | | *-----*
At this point, because the capacity function is a virtual
function and because a version of capacity is defined in
the box_car class, the box_car version is executed,
causing the appropriate volume to be returned.