![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
One step that is easy to take is to convert the display_capacity
function, which displays but returns nothing, into capacity
, a
function that displays nothing but returns a capacity. Recall that
display_capacity
is defined as follows in the railroad_car
class definition:
virtual void display_capacity ( ) { }
Further recall that display_capacity
is defined as follows in the
box_car
and tank_car
class definitions:
virtual void display_capacity ( ) {cout << volume ( );}
Using those definitions as a model, you might define
capacity
in the railroad_car
class
definition as follows:
virtual double capacity ( ) {return 0.0;}
And you might define capacity
this way in the
box_car
and tank_car
class definitions:
virtual double capacity ( ) {return volume ( );}