Help on separating classes/functions

I'm trying to separate my program into 3 cause that's what our professor wants us to do. However, I'm having issue after issue, can I get any assistance please? I'd appreciate it.

My 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
33
34
35
36
37
38
39
40
#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.
		{
			name = " ";
			department = " ";
			position = " ";
			idNumber = 0;
		}

		void setName (string EmpName);
		void setIDNum (int idNum);
		void setDesc (string Desc);
		void setPos (string Pos);
		void e1 (string EmpName, int EmpID,
				 string Dept, string Position);
		void e2 (string EmpName, int idNum);

		string getName() const {return name;} 
		int getIDNum() const {return idNumber;}
		string getDesc() const {return department;} 	
		string getPos() const {return position;}
		string e1() const {return e1;}
		string e2() const {return e2;}
};
#endif 


Employee 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
#include "Employee.h"

// Constructor 1 with arguments as parameters.
void Employee::e1 (string EmpName, int EmpID,
			  string Dept, string Position)
{
	name = EmpName;
	idNumber = EmpID;
	department = Dept;
	position = Position;
}

// Constructor 2 with arguments as parameters.
void Employee::e2 (string EmpName, int idNum)
{
	name = EmpName;
	idNumber = idNum;
	department = " ";
	position = " ";
}

// 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, and e3.
	Employee::e1 ("Susan Meyers", 47899,
		"Accounting", "Vice President");

	Employee::e1 ("Mark Jones", 39119,
		"IT", "Programmer");

	Employee::e1 ("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.getDesc() << "\t" << e1.getPos() << endl;

	cout << e1.getName() << "\t" << e1.getIDNum() << "\t\t"
		 << e1.getDesc() << "\t" << e1.getPos() << endl;

	cout << e1.getName() << "\t" << e1.getIDNum() << "\t\t"
		 << e1.getDesc() << "\t" << e1.getPos() << endl;
}
issue after issue

In what way? Compiler errors? Program crash? Incorrect results? Other?
Its not liking things such as:

1
2
cout << e1.getName() << "\t" << e1.getIDNum() << "\t\t"
		 << e1.getDesc() << "\t" << e1.getPos() << endl;

I did have it e1, e2, and e3 for the three employees before the professor wanted this change.

And in this one:
1
2
Employee::e2 ("Mark Jones", 39119,
		"IT", "Programmer");

Its not liking the name of the person if I change it to Employee::e2 I get the red line under the name and Employee I think.
Shouldn't you have something like this:
1
2
3
4
5
6
7
8
9
	// Three employee objects called a, b , and c.
	Employee a("Susan Meyers", 47899,
		"Accounting", "Vice President");

	Employee b("Mark Jones", 39119,
		"IT", "Programmer");

	Employee c("Joy Rodgers", 81774,
		"Manufacturing", "Engineer");


And then define an appropriate constructor in employee.h
1
2
3
4
5
        Employee(string EmpName, int EmpID, string Dept, string Position) :
            name(EmpName),
            position(Position),
            department(Dept),
            idNumber(EmpID) { }


Topic archived. No new replies allowed.