In this program we will create a class of employee, create its setter and getter functions and call them in main().
//Code Starts
void emp::display()
//Code Starts
#include<iostream>
#include<conio.h>
using namespace std;
class emp{
private : int
salary;
char name[20],desig[50],resp[50];
public:
void
setsalary();
void
setname();
void
setdesig();
void
setresp();
int
getsalary();
int
getname();
int
getdesig();
int
getresp();
void
display();
};
void
emp::setsalary() {
cout<<"Enter
Salary of Employee: ";
cin>>salary;
}
void
emp::setname() {
cout<<"Enter
name of employee : ";
cin>>name;
\ }
void
emp::setdesig()
{
cout<<"Enter designation of employee : ";
{
cout<<"Enter designation of employee : ";
cin>>desig;
}
void
emp::setresp()
{
{
cout<<"Enter
Resposibility of "<<name<<" : ";
cin>>resp;
}
int
emp::getsalary()
{
return
salary;
}
void emp::display()
{
cout<<name<<"
works in company as "<<desig<<"
"<<resp<<" on salary of RS."<<salary;
if(salary<=20000)
{
cout<<"Salary
is average";
}
else{
cout<<"Above
average salary";
}
}
int main()
{
emp e1;
for(int
i=1;i<=2;i++)
{
e1.setname();
e1.setdesig();
e1.setresp();
e1.setsalary();
e1.display();
cout<<endl;
}
getch();
}
//Code ends
0 comments:
Post a Comment