In our Employee
case study, each concrete class provides its own implementation for virtual
functions earnings
and print
. You’ve learned that each class which inherits directly from abstract base class Employee
must implement earnings in order to be a concrete class, because earnings
is a pure virtual
function. These classes do not need to implement function print
, however, to be considered concrete—print
is not a pure virtual
function and derived classes can inherit class Employee
’s implementation of print
. Furthermore, class BasePlusCommissionEmployee
does not have to implement either function print
or earnings
—both function implementations can be inherited from concrete class CommissionEmployee
. If a class in our hierarchy were to inherit function implementations in this manner, the vtable pointers for these functions would simply point to the function implementation that was being inherited. For example, if BasePlusCommissionEmployee
did not override earnings
, the earnings
function pointer in the vtable for class BasePlusCommissionEmployee
would point to the same earnings
function as the vtable for class CommissionEmployee
points to.