This chapter introduced inheritance—the ability to create classes by absorbing an existing class’s members and enhancing them with new capabilities. You learned the notions of base classes and derived classes and created a derived class that inherits members from a base class and overrides inherited virtual
methods. We introduced access modifier protected
; derived-class members can access protected
base-class members. You learned how to access base-class members with base
. You also saw how constructors are used in inheritance hierarchies. Finally, you learned about the methods of class object
, the direct or indirect base class of all classes.
In Chapter 12, we build on our discussion of inheritance by introducing polymorphism—an object-oriented concept that enables us to write apps that handle, in a more general manner, objects of a wide variety of classes related by inheritance. After studying Chapter 12, you’ll be familiar with classes, objects, encapsulation, inheritance and polymorphism—the most essential aspects of object-oriented programming.