USING C++ VISUAL STUDIO COMPILER PLEASE SOLVE ASSIGNMENT FULLY FOR BEST ANSWER S
ID: 663741 • Letter: U
Question
USING C++ VISUAL STUDIO COMPILER PLEASE SOLVE ASSIGNMENT FULLY FOR BEST ANSWER SHOW OUTPUT
Objective:
To gain experience on creating derived classes and inheritance.
Project Description
Take the code we've provided for the Employee class (Employee.h) and the Manager class (Manager.h).
Add methods to the classes named:
that let users change the corresponding fields. Take advantage of the inheritance relationship between Employee and Manager--you only need to add each of those methods to 1 class.
Write a Supervisor class. A supervisor is responsible for employees in a specific department and must:
Have a field to store the department name (as a string).
Have getDept() and setDept() methods to access the department field.
Always be salaried (i.e., pay for a single pay period is fixed, no matter how many hours are worked).
Have a constructor that takes initial values for all fields.
What class should Supervisor inherit from?
CREATE Supervisor.h header file
Your code should compile and run correctly with the test program: Empltest.cpp.
THIS IS MY SUPERVISOR.H FILE SO FAR IT HAS SOME ERRORS AND WONT COMPILE PROPERLY WITH THE .CPP PROVIDED. I NEED to add methods to the class names setName() setPayRate() and setSalaried()
Here is my SUPERVISOR.h file
#ifndef _SUPERVISOR_H
#define _SUPERVISOR_H
#include "employee.h"
class Supervisor : public Manager {
public:
Supervisor(string name, float salary, string dept);
string getDept();
void setDept(string s);
float pay();
private:
string dept;
float salary;
};
Supervisor::Supervisor(string name, float salary, string dep):Manager(name, salary,true){
dept = dep;
}
Supervisor::setDept(string s){
dept = s;
}
Supervisor::getDept(){
return dept;
}
Explanation / Answer
Your code should compile and run correctly with the test program: Empltest.cpp.
THIS IS MY SUPERVISOR.H FILE SO FAR IT HAS SOME ERRORS AND WONT COMPILE PROPERLY WITH THE .CPP PROVIDED. I NEED to add methods to the class names setName() setPayRate() and setSalaried()
Here is my SUPERVISOR.h file
#ifndef _SUPERVISOR_H
#define _SUPERVISOR_H
#include "employee.h"
class Supervisor : public Manager {
public:
Supervisor(string name, float salary, string dept);
string getDept();
void setDept(string s);
float pay();
private:
string dept;
float salary;
};
Supervisor::Supervisor(string name, float salary, string dep):Manager(name, salary,true){
dept = dep;
}
Supervisor::setDept(string s){
dept = s;
}
Supervisor::getDept(){
return dept;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.