Summary
In this chapter, we've covered some further topics on OOP, starting with inheritance. We saw how we can use this to define behaviors in a base class, then inherit from that to create a derived class. Our derived classes specialize these more generic base classes, inheriting any public and protected members while defining their own as well. We can go on to create chains of inheritance or inherit from more than one class at a time to create complex objects.
We then looked at virtual member functions. When we declare functions in base classes, we can mark them as virtual, meaning their implementation can be overridden. Derived classes can provide their own implementations for virtual functions, should they wish to. If, however, a function is marked as pure virtual—and thus the base class is abstract—then the deriving class must provide a definition or become abstract as well.
This led to polymorphism and type casting. With objects that share a similar...