Homework 5 - Inheritance and Polymorphism

Due: Wednesday, March 4, 2009 at 5:00pm

Coding Conventions

Use the same coding conventions as described in Homework 1. Additionally, make sure to indent each section of the class in the class definition.

Assignment

The purpose of this assignment is to create two children classes that use polymorphism for some of their functions.

You will define the following class hierarchy:

                 Employee
                 /      \
                /        \
               /          \
       hourlyEmployee    salariedEmployee
The Employee class will be similar to, but NOT identical to, the class used in Lab 6. Use hw5main.cpp as your main function. Note that it uses a parent class pointer to call the polymorphic function. If you use seperate compilation, you will need to modify hw5main.cpp to include the filenames you use for your header files. Also, be sure to submit all files (header files, implementation files and the modified hw5main.cpp) if you use seperate compilation. Alternatively, you can just code all of these class within hw5main.cpp and submit just that file.

Use the following lists of features to code each class.

Employee class

The is the parent class. It will define the name and social security number. Unlike Lab 6, it will have no useful public functions for the outside world to use. Most of the functions will be in the protected section for the two children class to access. The only public functions will be the ones used for polymorphism.
Private section
Protected section
Public section

hourlyEmployee class

This class inherits from the Employee class publically. It defines an employee who gets paid by the hour. Be sure to verify that the hours worked are positive and that the rate is above minimum wage.
Private section
Public section

salariedEmployee class

This class inherits from the Employee class publically. It defines an employee who gets paid a fixed, monthly salary. Be sure to verify that the monthly salary is positive.
Private section
Public section