Hi I'm a beginner and I need some help with designing this program. It basically asks to make a class named Employee that has these variables: Name, Id Number, Department and Position.
The class should have these constructors:
1- A constructor that accepts the arguments: Employee Name, Id Number, Department and Position. Then assigns them to their member variables.
2-A constructor that accepts these values as arguments then assigns them to their member variables:Employee name, Id Number.The department and position should be assigned an empty string("").
3- A default constructor that assigns empty strings("") to the name, department and position member variables, and ) to the Id number member variable.

After that I'm supposed ask the user to enter the Employee name, Id Number,Department and Position for three employees and store it in three objects then display the data for eah employee on the screen.

So far this is what I have :

#include <iostream>
using namespace std;

class Employee
{
	private:
		string Name;
		int IdNumber;
		string Department;
		string Position;
	public:
		Employee(string AssignName,int AssignIdNumber,string AssignDepartment,string AssignPosition)                       
		{
			Name=AssignName;
			IdNumber=AssignIdNumber;
			Department=AssignDepartment;
			Position=AssignPosition;
		}
		Employee(string AssignName,int AssignIdNumber)
		{
			Name=AssignName;
			IdNumber= AssignIdNumber;
			Department="";
			Position="";
		}
		Employee()
		{
			Name="";
			IdNumber=0;
			Department="";
			Position="";
		}
		void setName(string);
		void setIdNumber(int);
		void setDepartment(string);
		void setPosition(string);
		string getName() const;
		int getIdNumber() const;
		string getDepartment() const;
		string getPosition () const;
};

void Employee::setName(string N)
{
	Name = N;
}

void Employee::setIdNumber(int ID)
{
	IdNumber = ID;
}
void Employee::setDepartment(string Depart)
{
	Department = Depart;
}
void Employee::setPosition (string Pos)
{
	Position = pos;
}

string Employee::getName() const
{
	return Name;
}
int Employee::getIdNumber() const
{
	return IdNumber;
}
string Employee::getDepartment() const
{
	return Department;
}
string Employee::getPosition() const
{
	return Position;
}

int main()
{
	Employee info;
	string EmployeeName;
	int EmployeeIdNumber;
	string EmployeeDepartment;
	string EmployeePosition;

	//Get info from the use
	cout<<"What is the Employee's Name?";
	cin>>EmployeeName;
	cout<<"What is the Employee's Id Number?";
	cin>>EmployeeIdNumber;
	cout<<"What is the Employee's Department?";
	cin>>EmployeeDepartment;
	cout<<"What is the Employee's position?";
	cin>>EmployeePosition;

	//Store information in the info object
	info.setName(EmployeeName);
	info.setIdNumber(EmployeeIdNumber);
	info.setDepartment(EmployeeDepartment);
	info.setPosition(EmployeePosition);

	//Display Employee Data
	cout<<"Here's the employee's data:\n";
	cout<<"Name: "<<info.getName()<<endl;
	cout<<"Id Number: "<<info.getIdNumber()<<endl;
	cout<<"Department: "<<info.getDepartment()<<endl;
	cout<<"Position: "<<info.getPosition()<<endl;
	return 0;
}

First of all This has been kind of hard for me to comprehend but I tried my best and this is all I have. I don't know how to process each employee's data correctly...Please help I'm very desperate

It looks like you're close to having a working program.

Have you tried compiling? If so, you'd find that you have two errors. One is a missing #include and the other is a small typo. Find and fix those.

Then you'll find a problem if you try to enter a person's full name. Your input method ( cin >> employeeName) will only get one word. You need to use getline( ).

Once you have it working for one employee, then allocate a couple more. You could create separate variables for each, or create an array of employees, like this

Employee workers[3];
workers[0].setname( "John Smith" );

Comments
He's awesome he always helps me out.I understand his posts

One thing you can do is completely define the constructor that takes the most arguments, then use it in the other less specific constructors and pass it default arguments.

I'm kinda confused..so if I were to make it an array of Employees does that mean I have to make the Id Number and the rest of the information arrays as well?..I don't really get how to combine arrays and classes

No, you reuse the input strings in a loop, assigning to an element of the array as you go along. Consider this example.

#include <iostream>
using namespace std;

class Point
{
	private:
		int x;
		int y;
	public:
		Point( );
		Point( int in_x, int in_y );
		void set( int in_x, int in_y );
		void set_x( int in_x );
		void set_y( int in_y );
		int get_x( );
		int get_y( );
};

Point::Point( )
{
	x = 0;
	y = 0;
}

Point::Point( int in_x, int in_y )
{
	x = in_x;
	y = in_y;
}

void Point::set( int in_x, int in_y )
{
	x = in_x;
	y = in_y;
}

void Point::set_x( int in_x )
{
	x = in_x;
}

void Point::set_y( int in_y )
{
	y = in_y;
}


int Point::get_x( )
{
	return x;
}


int Point::get_y( )
{
	return y;
}



int main()
{
	Point single_1;
	Point single_2( 5, -8 );
	Point lots[5];

	int i;
	int temp;

        //fill in the array of points, one at a time
	for( i = 0; i < 5; i++ )
	{
		cout << "X value? : ";
		cin >> temp;
		lots[i].set_x( temp );
		cout << "Y value? : ";
		cin >> temp;
		lots[i].set_y( temp );
	}

	cout << single_1.get_x( ) << ", " << single_1.get_y( ) << endl;
	cout << single_2.get_x( ) << ", " << single_2.get_y( ) << endl;

	for( i = 0; i < 5; i++ )
		cout << lots[i].get_x( ) << ", " << lots[i].get_y( ) << endl;

	return 0;
}

Ya I realized I had the <string> missing thanks though. I appreciate your help vmanes. Thanks :) It's working now

This question has already been answered. Start a new discussion instead.