I'm trying to accomplish this with
emp2->popList(empList[numSales]);
I have a feeling i'm mixing up my types.. is it a pointer, not a pointer, etc.
Errors:
C:\Users\supercomputer\Desktop\Data Structures\Project4\main.cpp||In function 'int main()':| C:\Users\supercomputer\Desktop\Data Structures\Project4\main.cpp|94|warning: comparison between signed and unsigned integer expressions| obj\Debug\main.o||In function `main':| C:\Users\supercomputer\Desktop\Data Structures\Project4\main.cpp|76|undefined reference to `Employee::popList(Employee*)'| ||=== Build finished: 1 errors, 1 warnings ===|
Appreciate the help. Thanks for your time
main.cpp:
#include <cstdlib>
#include <iostream>
#include <vector>
#include "Auto.h"
#include "Home.h"
#include "Life.h"
#include "Salesperson.h"
#include "Manager.h"
using namespace std;
int main()
{
vector<Employee *> empList;
do{
cout << endl << "Insurance Record Keeping System" << endl;
cout << "---------------" << endl;
cout << "1. Add salesperson" << endl;
cout << "2. Add manager" << endl;
cout << "3. Print employee list" << endl;
cout << "4. Add policy" << endl;
int menuChoice;
cout << "Enter menu choice: ";
cin >> menuChoice;
switch (menuChoice)
{
case 1:
{
string tempNameS;
float tempBaseSalaryS;
cout << endl << "Creating Salesperson...";
cout << endl << "Enter name (ex: John_Doe): ";
cin >> tempNameS;
cout << "Enter base salary: ";
cin >> tempBaseSalaryS;
Employee * emp1 = new Salesperson(tempNameS, tempBaseSalaryS);
//shape1->calcArea();
empList.push_back(emp1);
break;
}
case 2:
{
string tempNameM;
float tempBaseSalaryM;
cout << endl << "Creating Manager...";
cout << endl << "Enter name (ex: John_Doe): ";
cin >> tempNameM;
cout << "Enter base salary: ";
cin >> tempBaseSalaryM;
Employee * emp2 = new Manager(tempNameM, tempBaseSalaryM);
cout << "Enter number of employees managed: ";
int numEmp;
cin >> numEmp;
for (int i = 0; i < numEmp; i++)
{
cout << "Enter index number of salesperson to add: ";
int numSales = 0;
cin >> numSales;
emp2->popList(tempSales);
//emp2.manList.push_back(empList[numSales]);
}
//shape2->calcArea();
empList.push_back(emp2);
break;
}
case 3:
{
cout << endl << "Printing all employees:" << endl;
for (int v =0; v < empList.size(); v++)
{
cout << "[" << v << "] " << empList[v]->getName() << endl;
}
break;
}
case 4:
{
// cout << endl << "Printing all areas:" << endl;
// for (int i =0; i < shapes.size(); i++)
// {
// shapes[i]->printArea();
// }
break;
}
case 5:
{
exit(1);
}
};
}
while(1);
return 0;
}
Employee.h:
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <iostream>
using namespace std;
class Employee
{
protected:
string name;
float baseSalary;
float commTotal;
float totalSalary;
float finalComm;
vector <Policy*> polVect;
public:
virtual void calcFinalComm() = 0;
virtual void calcTotalSal() = 0;
void popList(Employee*);
string getName()
{
return name;
}
//virtual void printArea() = 0;
// float getArea(){return area;}
};
#endif
Salesperson.h:
#include "Employee.h"
class Salesperson: public Employee
{
public:
Salesperson(string a="", float b=0)
{
name = a;
baseSalary = b;
}
void calcFinalComm()
{
finalComm = (commTotal) + (commTotal * .05);
}
void calcTotalSal()
{
totalSalary = baseSalary + finalComm;
}
void popList(Salesperson *)
{
}
};
Manager.h:
#include "Employee.h"
class Manager: public Employee
{
protected:
vector <Salesperson*> manList;
float empTotal;
public:
Manager(string a="", float b=0)
{
name = a;
baseSalary = b;
}
void popList(Salesperson* s)
{
manList.push_back(s);
}
void calcFinalComm()
{
finalComm = (commTotal) + (commTotal * .3) + (empTotal * .05);
}
void calcTotalSal()
{
totalSalary = baseSalary + finalComm;
}
};
This post has been edited by Phox: 30 July 2012 - 09:08 PM

New Topic/Question
Reply




MultiQuote




|