12.8. Case Study: Payroll System Using Polymorphism and Runtime Type Information with Downcasting, dynamic_cast, typeid and type_info
Recall from the problem statement at the beginning of Section 12.6 that, for the current pay period, our fictitious company has decided to reward
BasePlusCommissionEmployees by adding 10 percent to their base salaries. When processing
Employee objects polymorphically in Section 12.6.5, we did not need to worry about the “specifics.” Now, however, to adjust the base salaries of
BasePlusCommissionEmployees, we have to determine the specific type of each
Employee object at execution time, then act appropriately. This section demonstrates the powerful capabilities of runtime type information (RTTI) and dynamic casting ...