Summary
In this chapter, we have moved even further along our journey with object-oriented programming by understanding how virtual functions in C++ provide direct language support for the OO idea of polymorphism. We have seen how virtual functions provide dynamic binding of a specific method to an operation in our inheritance hierarchy.
We have seen how, using virtual functions, an operation specified by a base class can be overridden by a derived class, providing a more suitable implementation. We have seen that the correct method for each object can be selected using runtime binding, regardless of whether the object is stored in its own type or in a generalized type.
We have seen that objects are often generalized using base class pointers and how this can allow the uniform processing of related derived class types. We have seen that, regardless of how an instance is stored (as its own type or as that of a base class using a pointer), the correct version of a virtual function...