Declaring Inheritance
Up until this lesson, you have been using C++ as an object-based language. To be truly object-oriented, a language must be able to support inheritance.
Inheritance is the ability to create a new class whose capabilities are based on at least one other class (often called the superclass or ancestor). Inheritance has been called “programming by difference,” because the only code in the new class (called the derived class or descendant) is that which differs from the superclass.
Inheritance allows you to replace or add member functions or to add member variables to an existing class by creating a derived class and putting the changes in the new class. In most cases, you can do this without modifying the superclass.
You will ...
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