I keep coming up with error 2504 base class undefined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Calek916
    New Member
    • Nov 2011
    • 6

    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 getHealthInsura nce();
    void setHealthInsura nce(string healthIns);
    double getLifeInsuranc e();
    void setLifeInsuranc e(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(st ring first);
    string getLastName();
    void setLastName(str ing last);
    char getGender();
    void setgender(char gen);
    int getDependents() ;
    void setDependents(i nt dep);
    void setDependents(s tring 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::Emplo yee()
    {
    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::Emplo yee(string first, string last, char gen, int dep, double salary)
    {
    firstName = first;
    lastName = last;
    gender = gen;
    dependents = dep;
    annualSalary = salary;
    }
    benefit::benefi t(string health, double life, int vacation)
    {
    healthInsurance = health;
    lifeInsurance = life;
    vacationDays = vacation;
    }
    string Employee::getFi rstName()
    {
    return firstName;
    }
    void Employee::setFi rstName(string first)
    {
    firstName = first;
    }
    string Employee::getLa stName()
    {
    return lastName;
    }
    void Employee::setLa stName(string last)
    {
    lastName = last;
    }
    char Employee::getGe nder()
    {
    return gender;
    }
    void Employee::setge nder(char gen)
    {
    gender = gen;
    }
    int Employee::getDe pendents()
    {
    return dependents;
    }
    void Employee::setDe pendents(int dep)
    {
    dependents = dep;
    }
    void Employee::setDe pendents(string dep)
    {
    dependents = atoi(dep.c_str( ));
    }
    double Employee::getAn nualSalary()
    {
    return annualSalary;
    }
    void Employee::setAn nualSalary(doub le salary)
    {
    annualSalary = salary;
    }
    void Employee::setAn nualSalary(stri ng salary)
    {
    annualSalary = atof(salary.c_s tr());
    }
    double Employee::calcu latePay()
    {
    return annualSalary/52;
    }
    int Employee::getNu mEmployees()
    {
    return numEmployees;
    }

    string benefit::getHea lthInsurance()
    {
    return healthInsurance ;
    }
    void benefit::setHea lthInsurance(st ring healthIns)
    {
    healthInsurance = healthIns;
    }
    double benefit::getLif eInsurance()
    {
    return lifeInsurance;
    }
    void benefit::setLif eInsurance(doub le lifeIns)
    {
    lifeInsurance = lifeIns;
    }
    int benefit::getVac ationDays()
    {
    return vacationDays;
    }
    void benefit::setVac ationDays(int vacation)
    {
    vacationDays = vacation;
    }

    void Employee::displ ayEmployee()
    {
    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::displa yBenefit()
    {
    cout << "Health Insurance Type: " << healthInsurance << endl;
    cout << "Life Insurance Amount: " << lifeInsurance << endl;
    cout << "Vacation Days: " << vacationDays << " days" << endl;
    }
    int Employee::numEm ployees = 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::numEm ployees++;

    one.displayEmpl oyee();

    numEmpl = Employee::getNu mEmployees();
    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::numEm ployees++;

    two.displayEmpl oyee();

    numEmpl = Employee::getNu mEmployees();
    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;
    }
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Just a guess but it's probably because you declared Employee before iEmployee.

    Comment

    • Calek916
      New Member
      • Nov 2011
      • 6

      #3
      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::Emplo yee() 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.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        That's a new question. Please post a new thread for that.

        Comment

        Working...