FY-1-a Design an employee class in easy way

Design an employee class in C++

Design an employee class for reading and displaying the employee information, the
getInfo() and displayInfo() methods will be used repectively. Where getInfo() will
be private method

Click here to get other OOP Practical

FYIT practical 1-a

#include<iostream>
using namespace std;
class Employee
{
string ename, eid, edept, eadrs;
public:
Employee()
{
getInfo();
}

void displayInfo()
{
cout<<"n Name : "<<ename<<"n ID : "<<eid<<"n Department : "<<edept<<"n Address : "<<eadrs;
}

private:
void getInfo()
{
cout<<"Enter employee details";
cout<<"nName : ";
cin>>ename;
cout<<"ID : ";
cin>>eid;
cout<<"Department : ";
cin>>edept;
cout<<"Address : ";
cin>>eadrs;
}
};
//itvoyagers.in
int main()
{
Employee emp1 = Employee();
emp1.displayInfo();
return 0;
}

OUTPUT : 

Enter employee details
Name : Vikram
ID : 005
Department : BSc IT
Address : Mumbai

Name : Vikram
ID : 005
Department : BSc IT
Address : Mumbai

Check out more FYIT OOP Practical Program and other logic building programs in C++

Leave a Comment