Employee Class Problem

Program works fine but the "cout's" aren't showing... Can't seem to figure out whats wrong :o

This is the 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
41
42
43
44
#ifndef Employee_Header
#define Employee_Header
#include <sstream>
#include <iomanip>

using namespace std;

class Employee
{
	string name;
	string idnumber;
	string department;
	string position;
public:
	Employee ();
	Employee (string n, string id);
	Employee (string n, string id, string dept, string pos);
	string EmployeeInfo (void)
	{return (name, idnumber, department, position);}
};

Employee::Employee()
{
	string name = "";
	string idnumber = "";
	string department = "";
	string position = "";
}

Employee::Employee (string n, string id)
{
	string name = n;
	string idnumber = id;
}

Employee::Employee (string n, string id, string dept, string pos)
{
	string name = n;
	string idnumber = id;
	string department = dept;
	string position = pos;
}

#endif 


This is the main cpp file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "Employee_H.h"
#include <iostream>
using namespace std;

int main()
{
	Employee object1("Susan Meyers", "47899", "Accounting", "Vice President");
	Employee object2("Mark Jones", "39119", "IT", "Programmer");
	Employee object3("Roy Rogers", "81774", "Manufacturing", "Engineer");

	cout<< object1.EmployeeInfo() << endl;
	cout<< object2.EmployeeInfo() << endl;
	cout<< object3.EmployeeInfo() << endl;

	cin.ignore();
	cin.get();
	return 0;
}


thanks for checking this out !!!!! :D
return (name, idnumber, department, position);
You can't pass back multiple strings like that.

You can append them onto each other though with the + operator or you could return some sort of container such as an array or vector that stores the strings.
I'm really knew to c++ and I made this from scratch. If its too much to ask, can you show me what that would look like? I'm sure I'll understand it from there.
it all depends on what you are trying to do. Are you simply trying to return a string that is in the format of [name][' '][id][' '][dept][' '][pos]

for that it would look like:
 
return( name + " " + idnumber + " " + department + " " + position );


http://ideone.com/Crhjf4
Last edited on
Its for a programming assignment at school. I'm trying to create a Employee class with five different member variables. Then I have to create three objects with input data to go into the class placeholders then have it output on the screen.
Topic archived. No new replies allowed.