![]() |
![]() |
![]() |
![]() |
![]() |
|
Accordingly, you might decide to display load capacities by defining
display_capacity member functions in the box_car and
tank_car classes.
You now know, however, that the decision about which of those functions to
use must be determined at run time. Accordingly, you have to plant a
virtual display_capacity function in the railroad_car class:
railroad_car <-- Virtual display_capacity
^ ^ function announces
| | presence of virtual
*---------------------------* | functions lower in the
| *---------------------* hierarchy
| |
box_car tank_car <-- Virtual display_capacity functions in
box_car and tank_car compute volume