![]() |
![]() |
![]() |
![]() |
![]() |
|
Although you must be careful when you make assertions such as a box car is a box, such assertions are often expedient, especially if the word is can be taken to mean usefully can be viewed as.
For example, the following are plausible reasons why you might want to view a box car as a box and a tank car as a cylinder:
box and cylinder classes, you avoid needless duplication and
simplify maintenance.
box and
cylinder classes. To prevent the gratuitous introduction of bugs,
you would want to use those class definitions as they stand, rather than,
say, copying bits of those box and cylinder class definitions
into the box_car and tank_car class definitions.
box and cylinder
classes from a vendor, because you anticipate using the elaborate box and
cylinder capabilities advertised by that vendor. Because the vendor
supplies you with compiled code only, you cannot access the source code, so
you cannot copy bits of the vendor's box and cylinder class
definitions into your box_car and tank_car class definitions.
You can only define new classes that use those compiled classes as base
classes.