Inheritance
Inheritance is one of the most powerful aspects of classes. First off, classes allow you to modify a program without really making changes to it. To elaborate, by making a subclass through inheritance, you can change the behavior of the program by simply adding new components to it rather than rewriting the existing components.
As we've seen, an instance of a class inherits the attributes of that class. However, classes can also inherit attributes from other classes. Hence, a generic superclass (also known as a parent) can be specialized through subclasses (also called children), since the children classes inherit their general properties from the parent class. The subclasses can override the logic in a superclass, allowing you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access