Question: Declare and implement base class Employee (15 pts) Declare and implement derived class FulltimeEmployee (15 pts) Declare and implement derived class ParttimeEmployee (15 pts) Define
Declare and implement base class Employee (15 pts)
Declare and implement derived class FulltimeEmployee (15 pts)
Declare and implement derived class ParttimeEmployee (15 pts)
Define tester program. (10 pts)
Submit the project correctly. (5 pts)
Instructions
Define a C++ program to manage the employee information. You will define a base class Employee and two derived classes: FulltimeEmployee and ParttimeEmployee. Create employee objects, implement inheritance and polymorphism to display the following employee information ---
Define base class Employee with at least the following members
Data member name, title and email
Member function
Employee() - constructor with parameters
virtual void displayEmployee()
virtual function in order to be overridden in the derived classes and perform polymorphism in the tester program.
Display employees name, title and email.
Define derived class FulltimeEmployee inherits from Employee class with at least the following members
Data member salary
Member function
FulltimeEmployee() - constructor with parameters
void displayEmployee()
override base class Employees displayEmployee().
Display employees type and salary.
Define derived class ParttimeEmployee inherits from Employee class with at least the following members
Data member hourlyWage, hours
Member function
ParttimeEmployee() - constructor with parameters
double calcGrossPay() calculate and return weekly pay = hours * hourlyWage
void displayEmployee()
override base class Employees displayEmployee().
Display employees weekly pay.
This is the tester program, please review the code and copy it to your tester program, you may also define your tester program by yourself
int main()
{
// create FulltimeEmployee object
FulltimeEmployee emp1("Mary Davis", "Faculty", "md@waketech.edu", 60000.00);
// create ParttimeEmployee object
ParttimeEmployee emp2("Tom Fox", "Secretary", "tf@waketech.edu", 20.00, 30);
// create an array of base class Employee pointers
Employee* employees[2];
// assign the address of the two employee objects in the array
// both emp1 and emp2 are also Employee objects
employees[0] = &emp1;
employees[1] = &emp2;
// implement dynamic binding and polymorphism
for (int i = 0; i < 2; i++)
{
cout << "Employee " << i + 1 << endl;
// the same function call will generate different results depend on
// what employee object pointed to by the Employee pointer
employees[i]->displayEmployee();
cout << endl;
}
return 0;
}
Test your program and compress the whole project folder in a .zip file, submit the zip file to BB for credits.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
