At last, you have the following definitions for the box_car
and
tank_car
classes:
class box_car : public railroad_car, public box { public: // Default constructor: box_car ( ) : box (10.5, 9.5, 40.0) { } // Displayers: virtual void display_short_name ( ) {cout << "box";} virtual void display_capacity ( ) {cout << volume ( );} }; class tank_car : public railroad_car, public cylinder { public: // Default constructor: tank_car ( ) : cylinder (3.5, 40.0) { } // Displayers: virtual void display_short_name ( ) {cout << "tnk";} virtual void display_capacity ( ) {cout << volume ( );} };
The volume
function mentioned in the definition of the
box_car
display_capacity
function must be the volume
function inherited from the box
class. Similarly, the volume
function mentioned in the tank_car
display_capacity
function
must be the volume
function inherited from the cylinder
class.