November 2019
Beginner
804 pages
20h 1m
English
Inheritance is another important OOP concept. It allows you to abstract things away by reusing definitions. Let's take an analogy with the real world: cats and dogs are both animals. In an OO system, you can use inheritance to model the relationship between a given concept and its generalizations (that is, ancestors). When using inheritance, we define is-a relationships: a dog is an animal, a cat is an animal, and so on.
By using inheritance, you can regroup fields and methods that are common to a set of closely related classes in a common ancestor class. For example, in an Animal class, you could define fields such as Sex and Age, as well as methods such as breathe, move, and many others.
In OO terms, we ...
Read now
Unlock full access