473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

I keep coming up with error 2504 base class undefined

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;
}
Feb 7 '12 #1
3 2596
Rabbit
12,516 Expert Mod 8TB
Just a guess but it's probably because you declared Employee before iEmployee.
Feb 7 '12 #2
Thank you Rabbit for your help. I got it to work just fine. Now I am having a problem when I run my program instead of getting my Employee::Employee() which is where I ask for your first name, last name etc.Instead I get my benefit class to start and I do not have it called. Can you help.
Feb 8 '12 #3
Rabbit
12,516 Expert Mod 8TB
That's a new question. Please post a new thread for that.
Feb 8 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Markus Bertheau | last post by:
Hi, I don't quite get the paragraph in the docs about this. Here it is: "A well-known problem with multiple inheritance is a class derived from two classes that happen to have a common base...
3
by: Pete Nudd | last post by:
I have a system in which potentialy 100's of classes derive directly from a common base class. I will often have a pointer of the base class type which points to an object of a derived class. Now...
13
by: Walt Karas | last post by:
The following gives an error in the declaration of the member function x() of the class template Tpl, compiliing with a recent version of GCC under Solaris: class A { }; class B { }; ...
3
by: hazz | last post by:
The following classes follow from the base class ' A ' down to the derived class ' D ' at the bottom of the inheritance chain. I am calling the class at the bottom, "public class D" from a client...
6
by: Philip Warner | last post by:
I have a set of classes: C (base) C1 (inherits C) C2 (inherits C) ... Cn (inherits C) (the C1..Cn also have subclasses, but thats not really relevant to the question)
1
by: John Dalberg | last post by:
Running VS 2005 SP1. I am getting errors on pages which contain custom controls. A typical error looks like this: (This is from a test aspx page which only contains the custom control) Parser...
4
by: OiNutter | last post by:
Hi I have a web service with a reference to a class library with 2 classes; User: The base class Client: Inherits from User There are also some functions which return an object of type...
15
by: Juha Nieminen | last post by:
I'm sure this is not a new idea, but I have never heard about it before. I'm wondering if this could work: Assume that you have a common base class and a bunch of classes derived from it, and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.