Chapter 11. Inheritance

Inheritance is a powerful language feature and a primary characteristic of an object-oriented language. This chapter explores what inheritance is, how it helps programmers organize classes that more accurately reflect the real world, and how inheritance encourages code reuse and consistent design strategies.

Bundled with inheritance comes polymorphism, the ability to use objects consistently and correctly without knowing their exact type at compile time. This chapter presents virtual functions and dynamic binding, the C++ language features that implement polymorphism. We discuss abstract base classes as they relate to program design and demonstrate how virtual constructors build objects whose type is not known until run ...

Get Navigating C++ and Object-Oriented Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.