You are on page 1of 2

#include<iostream>

#include<string>
using namespace std;
class Employee
{
private:
string name;
int id;
string department;
string position;
public:
Employee();
void setName(string);
string getName() const;
void setId(int);
int getId() const;
void setDepartment(string);
string getDepartment() const;
void setPosition(string);
string getPosition() const;
void setInfo(string, int, string, string);
void getInfo();
void putInfo()const;
~Employee();
};
Employee::Employee()
{
name = "";
department = "";
position = "";
id = 0;
}
void Employee::setName(string s)
{
name = s;
}
string Employee::getName() const
{
return name;

}
void Employee::setId(int num)
{
id = num;
}
int Employee::getId() const
{
return id;
}
void Employee::setDepartment(string s)
{
department = s;
}
string Employee::getDepartment() const
{
return department;
}
void Employee::setPosition(string s)
{
position = s;
}
string Employee::getPosition() const
{
return position;
}
void Employee::setInfo(string nameStr, int num, string depStr, string posStr)
{
setName(nameStr);
setId(num);
setDepartment(depStr);
setPosition(posStr);
}
void Employee::putInfo() const
{
cout << getName() << " " << getId() << " " << getDepartment() <<
" " << getPosition() << '\n';
}
void Employee::getInfo()
{
cout << "Enter name: ";
getline(cin, name);
cout << "Enter ID: ";
cin >> id;
cin.ignore();
cout << "Enter department: ";
getline(cin, department);
cout << "Enter position: ";
getline(cin, position);

}
Employee::~Employee()
{
cout << "\nDestructor executed...";
}
int main()
{
Employee emp1, emp2, emp3, emp4, emp5;
emp1.getInfo();
emp2.getInfo();
emp3.getInfo();
emp4.getInfo();
emp5.getInfo();
cout << "\nName ID Department Position\n";
emp1.putInfo();
emp2.putInfo();
emp3.putInfo();
emp4.putInfo();
emp5.putInfo();
return 0;
}

You might also like