Hey guys and gals, I posted earlier regarding problems with my program being split into 3 files; a header, implementation and main. As my title says, I get that error in the main.cpp file. Any workarounds for this?
Header file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>
using namespace std;
class Employee
{
// Private members.
private:
string name,
department,
position;
int idNumber;
// Public members.
public:
Employee(); // Default constructor.
Employee(string EmpName, int idNum, int EmpID, string Dept, string Position)
Employee(string EmpName, int idNum);
Employee(string EmpName, int idNum, string Dept, string Pos);
void setName (string EmpName);
void setIDNum (int idNum);
void setDesc (string Dept);
void setPos (string Pos);
void getName();
void getIDNum();
void getDept();
void getPos();
};
#endif
|
Implementation file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include "Employee.h"
// Default constructor.
Employee::Employee()
{
name = " ";
idNumber = 0;
department = " ";
position = " ";
}
// Constructor 1 with arguments as parameters.
Employee::Employee (string EmpName, int idNum, int EmpID, string Dept, string Position)
{
name = EmpName;
idNumber = idNum;
department = Dept;
position = Position;
EmpID = idNumber;
}
// Constructor 2 with arguments as parameters.
Employee::Employee (string EmpName, int idNum, string Dept, string Pos)
{
name = EmpName;
idNumber = idNum;
department = Dept;
position = Pos;
}
// Mutator function for name.
void Employee::setName (string EmpName)
{
name = EmpName;
}
// Mutator function for idNum.
void Employee::setIDNum (int idNum)
{
idNumber = idNum;
}
// Mutator function for department.
void Employee::setDesc (string Desc)
{
department = Desc;
}
// Mutator function for position.
void Employee::setPos (string Pos)
{
position = Pos;
}
|
main file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include "Employee.h"
#include <iostream>
using namespace std;
int main(void)
{
// Three employee objects called e1, e2, e3
Employee e1 ("Susan Meyers", 47899,
"Accounting", "Vice President");
Employee e2 ("Mark Jones", 39119,
"IT", "Programmer");
Employee e3 ("Joy Rodgers", 81774,
"Manufacturing", "Engineer");
// Display the data in table format.
cout << "Name: \t \t ID Number: \t Department: \t Position:" << endl;
cout << e1.getName() << "\t" << e1.getIDNum() << "\t\t"
<< e1.getDept() << "\t" << e1.getPos() << endl;
cout << e2.getName() << "\t" << e2.getIDNum() << "\t\t"
<< e2.getDept() << "\t" << e2.getPos() << endl;
cout << e3.getName() << "\t" << e3.getIDNum() << "\t\t"
<< e3.getDept() << "\t" << e3.getPos() << endl;
}
|
|