Introduction to OOP
Chapter 8: Inheritance and Substitution:
Reuse of Code, Reuse of Concept
Why do we use inheritance? Basically there are two major motivations:
Reuse of code. Methods defined in the parent can be made available to the child without rewriting. Makes it easy to create new abstractions.
Reuse of concept. Methods described in the parent can be redefined and overridden in the child. Although no code is shared between parent and child, the concept embodied in the definition is shared.
An example of the latter from the case study in chapter 7, all graphical objects know how to
, Slide 07