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 - FreshJob – Latest IT & Tech Jobs

Friday, 27 December 2019

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

By Using Scope Resolution Operator
:: 👈 Scope Resolution Operator


#include<iostream.h>
#include<conio.h>
class employee
{
int no;
char nm[20];
float sal;
void displayInfo();
public:
void getInfo();
};
void employee::getInfo()
{
cout<<"Enter employee ID:";
cin>>no;
cout<<"Enter employee Name :";
cin>>nm;
cout<<"Enter employee Salary :";
cin>>sal;
displayInfo();
}
void employee:: displayInfo ()
{
cout<<"\nEmployee Number:"<<no;
cout<<"\nEmployee Name:"<<nm;
cout<<"\nEmployee Salary:"<<sal;
}
void main()
{
clrscr();
employee e;
e.getInfo();
getch();
}
Output
👇

No comments:

Post a Comment