April 2019
Intermediate to advanced
360 pages
9h 17m
English
Inheritance in programming is the same as in real life. A girl inherits from her mother, who inherits from her mother, and so on. The following diagram shows inheritance in the real world and how it relates to OOP:

On the left-hand side of the preceding diagram, a Grandmother passes down traits to the Daughter, who passes down traits to the Granddaughter. So, the Granddaughter inherits from both the Daughter and Grandmother. The same inheritance concept applies to our Bicycle class, which inherits from both the Two-Wheeled class and the Vehicle class. This is a powerful schema as it avoids class bloating. As ...
Read now
Unlock full access