Introduction to OOP | Chapter 8: Inheritance and Substitution: | next | previous | audio | real | text |
Our idealization of inheritance is captured in a simple rule-of-thumb.
Try forming the English sentences ``An A is-a B''. If it ``sounds right'' to your ear, then A can be made a subclass of B.
A dog is-a mammal, and therefore a dog inherits from mammal
A car is-a engine sounds wrong, and therefore inheritance is not natual. but a car has-a engine.