Motivation
After having written some notes on the four pillars of OOP, I did not quite understand what inheritance means. Decided to explore examples and finally understood it better.
The gist
- Inheritance enables creating a new class using attributes and methods of an existing class.
- The class from which attributes and methods are inherited from is called the superclass.
- The class which inherits the attributes and methods from the superclass is called the subclass.
This note will only talk about single inheritance. Multiple inheritance next time?
Example
1 | # superclass |