Question
Main.cpp #includeDate.h #includeEmployee.h #include #includeStaff.h #include #includeEducation.h #includeFaculty.h #includePartime.h #include using namespace std; int main() { vector em; Date dob1(12, 5, 1995); Staff *jack=new Staff(90,jack,peter,123,'F',dob1);
Main.cpp
#include"Date.h" #include"Employee.h" #include
Pastime.h
#pragma once
#include"Date.h"
#include"Employee.h"
#include
#include"Staff.h"
#include
using namespace std;
class Partime :public Staff {
private:
double hours;
public:
Partime() {};
Partime(double, double, string, string, int, char, Date);
double gethours() { return hours; };
void sethours(double hr) {
hours = hr;
};
double monthlyEarning() {
return getHourrate()*hours*4;
};
void Print() {
cout << "ID Employee number: " << ID << endl;
cout << "Employee firstname: " << f_name << endl;
cout << "Employee lastname: " << l_name << endl;
cout << "Birth date: " << db;
cout << "Hours works per month:$" << hours << endl;
cout << "Hourly rate:$" << getHourrate() << endl;
cout << "Monthly Salary:$" << monthlyEarning() << endl;
};
};
Partime.cpp
#include"Date.h"
#include"Employee.h"
#include
#include"Staff.h"
#include
#include"Partime.h"
using namespace std;
Partime::Partime(double hrs, double hrate, string ln, string fn, int id, char sex, Date dob):hours(hrs),Staff(hrate,ln,fn,id,sex,dob)
{
this->hours = hrs;
hrate = getHourrate();
this->l_name = ln;
this->f_name = fn;
this->ID = id;
this->sex = sex;
this->db = dob;
}
Faculty.h
#pragma once
#include"Date.h"
#include"Employee.h"
#include
#include
#include"Education.h"
using namespace std;
class Faculty :public Employee {
private:
string Level;
Education edu;
public:
Faculty(){};
Faculty(string,Education,string,string,int,char,Date);
string getLevel();
void setLevel(string);
double monthlyEarning();
void Print();
};
Faculty.cpp
#include"Date.h"
#include"Employee.h"
#include
#include
#include"Faculty.h"
using namespace std;
Faculty::Faculty(string lv, Education EDU, string ln, string fn, int id, char sex, Date dob) :Level(lv),edu(EDU), Employee(ln, fn, id, sex, dob)
{
this->Level = lv;
this->edu = EDU;
this->l_name = ln;
this->f_name = fn;
this->ID = id;
this->sex = sex;
this->db = dob;
}
string Faculty::getLevel()
{
return Level;
}
void Faculty::setLevel(string lv)
{
this->Level = lv;
}
double Faculty::monthlyEarning()
{
if (Level == "AS"||Level=="assistant professor"||Level=="assistant" || Level == "Assistant professor" || Level == "Assistant") {
return FACULTY_MONTHLY_SALARY;
}
else if (Level == "AO"||Level=="associate professor"|| Level == "associate"|| Level == "Associate professor"|| Level == "Associate") {
return FACULTY_MONTHLY_SALARY*1.2;
}
else if (Level == "FU"||Level=="Full"||Level=="professor"||Level == "Professor") {
return FACULTY_MONTHLY_SALARY*1.4;
}
}
void Faculty::Print()
{
cout << "ID Employee number: " << ID << endl;
cout << "Employee firstname: " << f_name << endl;
cout << "Employee lastname: " << l_name << endl;
cout << "Birth date: " << db;
cout << "Level: " << Level< cout << "Monthly salary:$" << monthlyEarning() << endl; edu.print(); } Staff.h #pragma once #include"Date.h" #include"Employee.h" #include #include using namespace std; class Staff :public Employee { private: double hourly_rate; public: Staff(); Staff(double,string,string,int,char,Date); double getHourrate(); void setHourrate(double); void Print(); double monthlyEarning(); }; Staff.cpp #include"Date.h" #include"Employee.h" #include #include"Staff.h" #include using namespace std; Staff::Staff() { } Staff::Staff(double hrate, string ln, string fn, int id, char sex, Date dob):hourly_rate(hrate),Employee(ln,fn,id,sex,dob) { this->hourly_rate = hrate; this->l_name = ln; this->f_name = fn; this->ID = id; this->sex = sex; this->db = dob; } double Staff::getHourrate() { return hourly_rate; } void Staff::setHourrate(double hrate) { this->hourly_rate = hrate; } double Staff::monthlyEarning() { return hourly_rate*160; } void Staff::Print() { cout << "ID Employee number: " << ID << endl; cout << "Employee firstname: " << f_name << endl; cout << "Employee lastname: " << l_name << endl; cout << "Birth date: " << db; cout << "Hourly rate:$" << hourly_rate << endl; cout << "Monthly Salary: " << monthlyEarning() << endl; } Employee.h #pragma once #include #include #include "Date.h" using namespace std; const int FACULTY_MONTHLY_SALARY = 5000.00; const int STAFF_MONTHLY_HOURS_WORKED = 160; class Employee { public: Employee(); Employee(string, string, int, char, Date); virtual void Print(); virtual double monthlyEarning() = 0;//pure virtual function to indicate the class is //abstract. WE DONT IMPLEMENT THIS FUNCTION IN THIS CLASS, BUT ALL CLASSES THAT INHERIT //THIS CLASS MUST IMPLEMENT THIS FUCNTION. string getLname(); void setLname(string); string getFname(); void setFname(string); int getId(); void setId(int); char getSex(); void setSex(char); Date getDate(); void setDate(Date); //more functions here. protected: string l_name; string f_name; int ID; char sex; Date db; }; Employee.cpp #include"Date.h" #include"Employee.h" #include #include using namespace std; Employee::Employee() { } Employee::Employee(string lastname, string firstname, int id, char sex, Date dob) { this->l_name = lastname; this->f_name = firstname; this->ID = id; this->sex = sex; this->db = dob; } string Employee::getLname() { return l_name; } void Employee::setLname(string ln) { this->l_name = ln; } string Employee::getFname() { return f_name; } void Employee::setFname(string fn) { this->f_name = fn; } int Employee::getId() { return ID; } void Employee::setId(int id) { this->ID = id; } char Employee::getSex() { return sex; } void Employee::setSex(char seex) { this->sex = seex; } Date Employee::getDate() { return db; } void Employee::setDate(Date dob) { this->db = dob; } void Employee::Print() { cout << "ID Employee number: " << ID << endl; cout << "Employee firstname: " << f_name< cout << "Employee lastname: " << l_name << endl; cout << "Birth date: " << db << endl; } Date.h #pragma once #include using namespace std; class Date { private: int month; int date; int year; public: Date(); Date(int d, int m, int y); void check_date(int d, int m, int y); string set_date()const; friend ostream& operator<<(ostream& dout, const Date& d); int getdate()const; void setdate(int day); int getmonth()const; void setmonth(int mon); int getyear()const; void setyear(int nian); }; Date.cpp #include"Date.h" #include using namespace std; Date::Date() { } Date::Date(int d, int m, int y) { this->date = d; this->month = m; this->year = y; check_date(d, m, y); } void Date::check_date(int d, int m, int y) { int months[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; while (true) { if (m >= 1 && m <= 12) { this->month = m; break; } else { cout << "Invalid.Month Must be between 1-12.Re-enter:"; cin >> m; continue; } } while (true) { if (d <= months[m - 1] && d>0) { this->date = d; break; } else { cout << "Invalid.Day Must be between 1-" << months[m - 1] << ".Re-enter:"; cin >> d; continue; } } while (true) { if (y >= 1 && y <= 2019) { this->year = y; break; } else { cout << "Invalid.Year must be positive or <=2019.Re-enter :"; cin >> y; continue; } } } string Date::set_date()const { string months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; return months[month - 1]; } ostream& operator<<(ostream& dout, const Date& d) { dout << d.set_date() << "," << d.date << "," << d.year << "." << endl; return dout; } int Date::getdate()const { return date; } void Date::setdate(int day) { this->date = day; } int Date::getmonth() const { return month; } void Date::setmonth(int mon) { this->month = mon; } int Date::getyear() const { return year; } void Date::setyear(int nian) { this->year = nian; } Education.h #pragma once #include #include #include"Employee.h" using namespace std; class Education { private: string Degree; string Major; int Research; public: Education(); Education(string, string, int); string getDegree(); void setDegree(string); string getMajor(); void setMajor(string); int getResearch(); void setResearch(int); void print(); }; Education.cpp #include #include #include"Education.h" #include"Employee.h" using namespace std; Education::Education() { } Education::Education(string dg, string mj, int rc) { this->Degree = dg; this->Major = mj; this->Research = rc; } string Education::getDegree() { return Degree; } void Education::setDegree(string dg) { this->Degree = dg; } string Education::getMajor() { return Major; } void Education::setMajor(string mj) { this->Major = mj; } int Education::getResearch() { return Research; } void Education::setResearch(int rc) { this->Research = rc; } void Education::print() { cout << "Degree: " << Degree << endl; cout << "Major: " << Major << endl; cout << "Research: " << Research << endl; } Implement a main() program that creates a vector pointers of class Employee to store the objects Staff, Faculty and Partime. When i run this code, error C2677 occur, please help me fix the code thanks.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started