In C++ Employees can behourly wage earners or paid an annual salary. So HourlyEm
ID: 3574928 • Letter: I
Question
In C++
Employees can behourly wage earners or paid an annual salary. So HourlyEmployees and SalaryEmployee can be derived from Employee. They differ in they are paid. In addition to annual pay the HourlyEmployee class should provide weeklyPay(). Assuming a full time hourly employee, pay is an hourly rate times 40 hours to give their pay per week and that times 52 to give their pay per year. Given the following class: Write a class called HourlyEmployee that derives from Employee. Only include data and function members that you need. Do not assume that Employee has needed values in the/*...*/sections. You may omit definition for getter and setter functions to save time.Explanation / Answer
Here is the code for you:
#include <iostream>
using namespace std;
class Date
{
int day;
int month;
int year;
};
class Employee //emp class
{
Date startDate;
public:
string fullName();
virtual int yearsOfService();
virtual double annualPay() = 0;
void setStartDate(int day, int month, int year);
Date getStartDate();
};
class HourlyEmployee : public Employee
{
double hourlyRate;
public:
double weeklyPay()
{
return hourlyRate * 40;
}
int yearsOfService();
double annualPay()
{
return weeklyPay() * 52;
}
};