Question: C++ Inheritance. Any help with this would be greatly appreciated :) Write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker
C++ Inheritance. Any help with this would be greatly appreciated :)
Write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:
Shift (an integer)
Hourly pay rate (a double)
// Specification file for the ProductionWorker Class
#ifndef PRODUCTION_WORKER_H
#define PRODUCTION_WORKER_H
#include "Employee.h"
#include
using namespace std;
class ProductionWorker: public Employee // write clause here to derive from Employee base class.
{
private:
// declare The worker's shift as int
int shift;
// declare The worker's hourly pay rate as a double
double payRate;
public:
// Default constructor
ProductionWorker() : Employee()
{ shift = 0; payRate = 0.0; }
// Constructor
ProductionWorker(string aName, string aNumber, string aDate,
int aShift, double aPayRate) : Employee(aName, aNumber, aDate)
{ shift = aShift; payRate = aPayRate; }
// Mutators
void setShift(int s)
{ shift = s; }
void setPayRate(double r)
{ payRate = r; }
// Accessors
int getShiftNumber() const
{ return shift; }
string getShiftName() const
{
// write the logic for the getshiftName() accessor
}
double getPayRate() const
{ return payRate; }
};
#endif
The workday is divided into two shifts: day and night. The shift variable will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2.
Write one or more constructors and the appropriate accessor and mutator functions for the class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
