Create an 'Employee' class with emp_id, emp_name and emp_gender as data members - member function to input the details of employee - member function to output the details of employee. Write a main function to create objects of Employee class. Take the input of 3 different employee from the user and display the details on the console output screen.
#include<iostream>
#include<string>
using namespace std;
class Employee
{
public:
char emp_name[30],emp_gender[7],emp_id[10];
void Input()
{
cout<<"\nEnter employee id : ";
cin.getline(emp_id,10);
cout<<"\nEnter name of employee : ";
cin.getline(emp_name,30);
cout<<"\nEnter gender of employee : ";
cin.getline(emp_gender,7);
}
void Output()
{
cout<<"\nEmployee ID : "<<emp_id;
cout<<"\nEmployee Name : "<<emp_name;
cout<<"\nGender : "<<emp_gender;
}
};
int main()
{
Employee e[3];
int i;
for(i=0;i<3;i++)
{
e[i].Input();
}
for(i=0;i<3;i++)
{
e[i].Output();
}
}
Comments
Leave a comment