![]() |
![]() |
![]() |
![]() |
![]() |
|
In the example used throughout the rest of this book, you are to assume
that a box car usefully can be viewed as a box and a tank car usefully can
be viewed as a cylinder. Consequently, you can move the height,
width, and length from the box_car class into the
box class, along with the volume member function that uses
those member variables, making those variables and that member function
more generally available. Similarly, you can move the radius and
length member variables from the tank_car class into the
cylinder class, along with the volume member function that
uses those member variables.
You can also declare a percentage_loaded member variable in the
container class alone, because subclasssuperclass relations
extending from the box_car and tank_car classes, through the
box and cylinder classes, to the container class,
ensure that all individual box_car and tank_car objects will
have percentage_loaded member variables.