Teacher starts the discussion: The main objective of inheritance is to promote reusability and eliminate redundancy (of code). The basic idea is that a child class can obtain the features/characteristics of its parent class. In programming terms, we say that a child class is derived from its parent/base class. Therefore, the parent class is placed at a higher level in the class hierarchy.
Types
In general, we deal with four types of inheritance.
- Single inheritance : A child class is derived from one base class
- Hierarchical inheritance : Multiple child classes can ...