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 ...

Get Core C++ A Software Engineering Approach 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.