Please remember our 05-25 Lab Exercise 2: class Employee
How to use Virtual function to solve the problem?
Design a class Employee represent all kinds of employees. TheEmployeee class should contain a member function getPay. The function getPay will return a integer value as the pay
Design Intern class represent a intern that inherit Employee class and implement the member function in Employee class.
Design PartTime class represent a part-time that inherit Employee class and implement the member function in Employee class. This class include attribute Hours-od-duty.
Design Fulltime class represent full-time that inherit Employee class and implement the member function in Employee class. This class include attribute monthly pay.
#include<iostream>
using namespace std;
class Employee
{
public:
//Your code: put virtual function here
};
class Intern : public Employee
{
public:
//Your code: Constructor initialize 0 and override function
};
class PartTime : public Employee
{
public:
//Your code: Constructor initialize 120 and override function
};
class FullTime : public Employee
{
public:
//Your code: Constructor initialize 50000 and override function
};
int main()
{
int money = 0;
PartTime user;
FullTime user2;
Intern user3;
money = user.getPay();
cout<<"Partime : " << money<<endl;
money = user2.getPay();
cout<<"Full time monthly pay : " << money<<endl;
money = user3.getPay();
cout<<"Intern : " << money<<endl;
return 0;
}