Next, derive a class called Hourly that adds a new data member to store an hourly wage (double). Its print function must print the social security number, name, date of hire, and salary (with phrase "per hour"). It will certainly want to call the base class print. Provide an accessor and mutator for the salary, and make sure that its constructor initializes a salary (how many parameters will the constructor need?).
Next, derive another class called Salaried that adds a new data member to store a yearly salary (double). Its print function must print the social security number, name, date of hire, and salary (with phrase "annual"). Provide an accessor and mutator for the salary, and make sure that its constructor initializes a salary.
Continue by creating a class called PtrToEmployee that stores a pointer to an Employee. It should provide print, operator<<, and operator< all of which apply the corresponding function to the Employee that is being pointed at, as well as a constructor that can be called to have the pointer point somewhere (presumably the result of a new). The constructor's default parameter should be NULL. Here is the class declaration for PtrToEmployee (seeing it may give you hints for some other stuff).
class PtrToEmployee
{
public:
PtrToEmployee( Employee *p = NULL );
void print( ostream & out = cout ) const;
bool operator< ( const PtrToEmployee &
rhs ) const;
private:
Employee *pointee;
};
ostream & operator<< ( ostream & out, const PtrToEmployee & rhs );
In order to hold all employees, create a class called Roster that is able to hold a variable number of PtrToEmployee objects. Roster should have a set of PtrToEmployee as its data member. The set should start with an initial size of 0, and can be expanded by calls to insert. Provide the capability to add an employee and print the entire roster of employees. The printing routine must print the employees in sorted order (as defined by Employee this means in increasing social security number).
To summarize, Roster has public methods add and print, and, as usual, an overloaded operator<<.
You should then be able to write a program that includes the following main:
int main( )
{
Roster r;
r.add( new Hourly( "Jim", "400-00-0000", Date(
"Nov", 1, 1992 ), 15.60 ) );
r.add( new Salaried( "Alex", "500-00-0000",
Date( "Oct", 1, 1994 ), 81090 ) );
r.add( new Hourly( "Mark", "600-00-0000", Date(
"Jul", 1, 1983 ), 21.75 ) );
r.add( new Hourly( "Bill", "100-00-0000", Date(
"Jan", 1, 1990 ), 10.90 ) );
r.add( new Salaried( "Bob", "200-00-0000", Date(
"Jun", 1, 1993 ), 61090 ) );
r.add( new Salaried( "Joe", "300-00-0000", Date(
"May", 1, 1996 ), 31690 ) );
r.add( new Salaried( "Tim", "700-00-0000", Date(
"Jun", 1, 1973 ), 111577 ) );
cout << r << endl;
return 0;
}