Exercises, First Set

1.Rewrite the DrugStockItem class that you wrote in Chapter 9 as a derived class of DatedStockItem, using virtual functions to allow DrugStockItem objects to be used in place of StockItem objects or DatedStockItem objects, just as you can use DatedStockItem objects in place of StockItem objects.
2.Rewrite the Employee class that you wrote in Chapter 9 as three classes: a base Employee class, an Exempt class and an Hourly class. The latter two classes will be derived from the base class. The virtual CalculatePay member function for each of these derived classes should use the appropriate method of calculating the pay for each class so that an Exempt object or an Hourly object can be substituted for an Employee class object. The Employee class CalculatePay function should display an error message, as that class does not have a method of calculating pay. Note that unlike the first Employee exercise in Chapter 9, you must maintain the same interface for the CalculatePay function in these classes because you are using a base class pointer to derived class objects.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset