I am trying to write this code that has an abstract class of iEmployee. I created the class and I am trying to get the Employee class to use it. I keep coming up with an error 2504 base class undefined. Can you please help me figure out why and how can I fix it.
#include <iostream>
#include <stdlib.h>
#include <string>
#include <iomanip>
using namespace std;
class benefit
{
private:
string healthInsurance;
double lifeInsurance;
int vacationDays;
string PPO;
string HMO;
public:
benefit();
benefit(string health, double life, int vacation);
void displayBenefit();
string getHealthInsurance();
void setHealthInsurance(string healthIns);
double getLifeInsurance();
void setLifeInsurance(double lifeIns);
int getVacationDays();
void setVacationDays(int vacation);
};
class Employee : public iEmployee
{
private:
string firstName;
string lastName;
char gender;
int dependents;
double annualSalary;
benefit Benefit;
public:
Employee();
Employee(string first, string last, char gen, int dep, double salary);
double calculatePay();
void displayEmployee();
string getFirstName();
void setFirstName(string first);
string getLastName();
void setLastName(string last);
char getGender();
void setgender(char gen);
int getDependents();
void setDependents(int dep);
void setDependents(string dep);
double getAnnualSalary();
void setAnnualSalary(double salary);
void setAnnualSalary(string salary);
static int getNumEmployees();
static int numEmployees;
};
class iEmployee abstract
{
public:
virtual double calculatePay() = 0;
};
void displayDivider(string outputTitle)
{
cout << "**************** " + outputTitle + " ****************" << endl;
}
Employee::Employee()
{
firstName = "Not Given";
lastName = "Not Given";
gender ='U';
dependents = 0;
annualSalary = 20000;
cout << "Please Enter The Employee's First Name: ";
cin >> firstName;
cout << "Please Enter The Employee's Last Name: ";
cin >> lastName;
cout << "Please Enter The Employee's Gender: ";
cin >> gender;
if (gender == 'M' || gender == 'm')
gender = 'M';
else if (gender == 'F' || gender == 'f')
gender = 'F';
else
gender = 'U';
cout << "Please Enter The Employee's Dependent Count: ";
cin >> dependents;
while (dependents < 0 || dependents > 10)
{
cout << "Please Enter A Number Between 0 And 10: ";
cin >> dependents;
}
cout << "Please Enter The Employee's Yearly Salary: ";
cin >> annualSalary;
while (annualSalary < 20000 || annualSalary > 150000)
{
cout << "Please Enter The Employee's Annual Salary Between 20,000 And 150,000: ";
cin >> annualSalary;
}
}
Employee::Employee(string first, string last, char gen, int dep, double salary)
{
firstName = first;
lastName = last;
gender = gen;
dependents = dep;
annualSalary = salary;
}
benefit::benefit(string health, double life, int vacation)
{
healthInsurance = health;
lifeInsurance = life;
vacationDays = vacation;
}
string Employee::getFirstName()
{
return firstName;
}
void Employee::setFirstName(string first)
{
firstName = first;
}
string Employee::getLastName()
{
return lastName;
}
void Employee::setLastName(string last)
{
lastName = last;
}
char Employee::getGender()
{
return gender;
}
void Employee::setgender(char gen)
{
gender = gen;
}
int Employee::getDependents()
{
return dependents;
}
void Employee::setDependents(int dep)
{
dependents = dep;
}
void Employee::setDependents(string dep)
{
dependents = atoi(dep.c_str());
}
double Employee::getAnnualSalary()
{
return annualSalary;
}
void Employee::setAnnualSalary(double salary)
{
annualSalary = salary;
}
void Employee::setAnnualSalary(string salary)
{
annualSalary = atof(salary.c_str());
}
double Employee::calculatePay()
{
return annualSalary/52;
}
int Employee::getNumEmployees()
{
return numEmployees;
}
string benefit::getHealthInsurance()
{
return healthInsurance;
}
void benefit::setHealthInsurance(string healthIns)
{
healthInsurance = healthIns;
}
double benefit::getLifeInsurance()
{
return lifeInsurance;
}
void benefit::setLifeInsurance(double lifeIns)
{
lifeInsurance = lifeIns;
}
int benefit::getVacationDays()
{
return vacationDays;
}
void benefit::setVacationDays(int vacation)
{
vacationDays = vacation;
}
void Employee::displayEmployee()
{
cout << "Employee Information" << endl;
cout << "_________________________________________________ __________________________________________" << endl;
cout << endl;
cout << "First Name: " << firstName << endl;
cout << "Last Name: " << lastName<< endl;
cout << "Gender: " << gender << endl;
cout << "Dependent(s): " << dependents << endl;
cout << "Annual Salary: " << setprecision(2) << showpoint << fixed << annualSalary << endl;
cout << "Weekly Pay: " << calculatePay() << endl;
}
void benefit::displayBenefit()
{
cout << "Health Insurance Type: " << healthInsurance << endl;
cout << "Life Insurance Amount: " << lifeInsurance << endl;
cout << "Vacation Days: " << vacationDays << " days" << endl;
}
int Employee::numEmployees = 0;
int main()
{
int numEmpl;
cout << "Welcome to your first Object Oriented Programming -- Employee ClassCIS247C, Week 2 Lab" << endl;
cout << "NAME: Brandon Braaten" <<endl;
displayDivider("Employee One");
Employee one;
Employee::numEmployees++;
one.displayEmployee();
numEmpl = Employee::getNumEmployees();
cout << "--- Number Of Employee Object Created ---" << endl;
cout << "Number Of Employees: " << numEmpl << endl;
displayDivider("Employee Two");
Employee two("Mary", "Noia", 'F', 5, 24000.00);
Employee::numEmployees++;
two.displayEmployee();
numEmpl = Employee::getNumEmployees();
cout << "--- Number Of Employee Object Created ---" << endl;
cout << "Number Of Employees: " << numEmpl << endl;
cout << "The end of the CIS 247C Week 6 iLab." << endl;
system ("pause");
return 0;
}