Summary
In this chapter, we looked at advanced uses of inheritance. They all rotate around the fact that base classes and derived classes have some capabilities in common; hence, objects of one class can be used instead of objects of another class, at least in some circumstances.
You saw that it is always safe to use an object of the derived class where an object of a base class is expected. This conversion is safe, but it is not very interesting. This derived object will be asked to do only things that a base object could do, and the derived class object can do much more.
However, the same is true about pointers (and references), and this is much more interesting. This means that you can use a pointer of the base class where a derived class ...
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