Employee基礎類別,Employee包含getPay函數。請設計衍生類別Intern、PartTime跟FullTime,PartTime類別裡含有工作時數這個屬性,FullTime這類別裡含有月薪這個屬性,Intern不支薪,請再衍生類別裡實作基礎類別裡的函數。
Design a class Employee represent all kinds of employees. The Employee class should contain a member function getPay. The function getPay() will return an integer value as the payment
Design Intern class represent an intern that inherit Employee class and implement the member function in Employee class.
Design PartTime class represents a part-time that inherit Employee class and implement the member function in Employee class. This class includes attribute hours-of-duty.
Design Fulltime class represent full-time that inherit Employee class and implement the member function in Employee class. This class includes attribute monthly pay.
Remember that YOU CAN ONLY ADD YOUR CODE INSIDE THE SPECIFIC AREA
#include<iostream>
using namespace std;
class Employee
{
//your code here
};
class Intern : public Employee
{
//your code here
};
class PartTime : public Employee
{
//your code here
};
class FullTime : public Employee
{
//your code here
};
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;
}
Expected output:
Partime : 120
Full time monthly pay : 50000
Intern : 0