/*Function to get employee information*/
void Employee::input() {
cout << "\nEnter ID : ";
cin >> id;
cout << "Enter Name : ";
cin >> name;
cout << "Enter Salary : ";
cin >> sal;
}
/*Function to print employee information*/
void Employee::output() {
cout << "\nId \t: " << id;
cout << "\nName \t: " << name;
cout << "\nSalary \t: " << sal;
}
/*function to get maximum salary of employees*/
void Employee::showMaxSal(Employee& e){
cout<<"Employee Having maximum salary : "<<endl;
if(sal>e.sal)
output();
else if(e.sal>sal)
e.output();
else{
output();
e.output();
}
}
/*Function to return salary of employee*/
float Employee::getSal(){
return sal;
}
/************ Main ************/
#include"empfunction.h"
#define SIZE 3
int main(int argc, char const *argv[])
{
/*Creating array of employee objects*/
Employee emp[SIZE],empMaxSal;
/*accepting employee data */
for (int i = 0; i < SIZE; ++i)
{
emp[i].input();
}
/*printing employee data*/
// cout<<"\nEmployee Details of "<<SIZE<<endl;
for (int i = 0; i < SIZE-1; ++i)
{
/*assign first obj as maximum salary object*/
empMaxSal=emp[i];
for (int j = i+1; j < SIZE ; ++j)
{
if(emp[i].getSal() < emp[j].getSal())
empMaxSal=emp[j];
}
}
cout<<"Details of employee with Maximum Salary : "<< endl;
empMaxSal.output();
return 0;
}
/*Cant get desired output, it is showing last entered record*/