Question: / / * * * * * * * * * * * * * * * * * * * * * * *

//******************************************************
//This is the HEADER FILE employee.h.
//This is the INTERFACE for the class Employee.
//This is primarily intended to be used as a base class to derive
//classes for different kinds of employees.
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include
using namespace std;
namespace employees
{
class Employee
{
public:
Employee();
Employee(string new_name, string new_ssn);
string get_name();
string get_ssn();
void change_name(string new_name);
void change_ssn(string new_ssn);
void print_check();
void give_raise(double amount);
protected:
string name;
string ssn;
double net_pay;
};
}//employees
#endif //EMPLOYEE_H
//******************************************************
2. File employee.cpp contains the definition of member function for employees class.
3. hourlyemployee.h is the interface of derived class HourlyEmployee.
The derived HourlyEmployee class, in addition to all member functions and variable members that it inherits from the Employee class, has several additional member functions and variable members defined in its body.
It is possible to take a member function from the parent's class and redefine it in the body of the child class. This is called redefining the inherited member function. For example, the print_check function is redefined in the HourlyEmployee class. To redefine a function, simply list it in the class definition and give it a new definition, just as you do with any other function.
4. salariedemployee.h is the interface of another derived class SalariedEmployee.
The derived class is SalariedEmployee and again has additional member functions and variable members to the ones that are already inherited from the Employee class.
Requirement:
Use the above three header files and the following two implementation programs, hourlyemployee.cpp, and salariedemployee.cpp. Redefine the function give_raise in both HourlyEmployee and SalariedEmployee such that:
1) Hourly_bases employees receive 10% raise on their hourly rate (wage_rate)
2) Salaried employees receive 6% raise of their salary
//This is the HEADER FILE salariedemployee.h.
//This is the INTERFACE for the class SalariedEmployee.
#ifndef SALARIEDEMPLOYEE_H
#define SALARIEDMPLOYEE_H
#include
#include "employee.h"
using namespace std;
namespace employees
{
class SalariedEmployee : public Employee
{
public:
SalariedEmployee();
SalariedEmployee (string new_name, string new_ssn, double new_weekly_salary);
double get_salary();
void change_salary(double new_salary);
void print_check();
void give_raise(double amount);
private:
double salary; //weekly
};
}//employees
//This is the HEADER FILE hourlyemployee.h.
//This is the INTERFACE for the class HourlyEmployee.
#ifndef HOURLYEMPLOYEE_H
#define HOURLYEMPLOYEE_H
#include
#include "employee.h"
using namespace std;
namespace employees
{
class HourlyEmployee : public Employee
{
public:
HourlyEmployee();
HourlyEmployee(string new_name, string new_ssn, double new_wage_rate, double new_hours);
void set_rate(double new_wage_rate);
double get_rate();
void set_hours(double hours_worked);
double get_hours();
void give_raise(double amount);
void print_check();
private:
double wage_rate;
double hours;
};
}//employees
#endif //HOURLYMPLOYEE_H
//******************************************************
//This is the HEADER FILE employee.h.
//This is the INTERFACE for the class Employee.
//This is primarily intended to be used as a base class to derive
//classes for different kinds of employees.
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include
using namespace std;
namespace employees
{
class Employee
{
public:
Employee();
Employee(string new_name, string new_ssn);
string get_name();
string get_ssn();
void change_name(string new_name);
void change_ssn(string new_ssn);
void print_check();
void give_raise(double amount);
protected:
string name;
string ssn;
double net_pay;
};
}//employees
#endif //EMPLOYEE_H
//******************************************************

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!