/*
Def : WAP to create a class Employee and declare empno,name,
salary and city as data memebers.Accept data from user and
print them for n employees using concept of Array of objects.
Tut. Date :
Lab Date :
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class Employee
{
private:
int empno,salary; // Data memebers
char name[20],city[20];
public:
void getData(); // member functions
void putData();
};
void Employee:: getData()
{
cout<<"\n Enter employee number : ";
cin>>empno;
cout<<"\n Enter employee name : ";
flushall();
gets(name);
cout<<"\n Enter employee salary : ";
cin>>salary;
cout<<"\n Enter employee city : ";
flushall();
gets(city);
}
void Employee::putData()
{
cout<<"\n Employee Number : "<<empno;
cout<<"\n Employee Name : "<<name;
cout<<"\n Employee Salary : "<<salary;
cout<<"\n Employee City : "<<city;
}
int main()
{
int n,i;
clrscr();
Employee emp[10];
cout<<"\n Enter the no of employee (Maximum 10) : ";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"\n Enter employee "<<(i+1)<<" details : ";
cout<<"\n==========================================";
emp[i].getData();
cout<<"\n==========================================";
}
cout<<"\n\n";
for(i=0;i<n;i++)
{
cout<<"\n Employee "<<(i+1)<<" details : ";
cout<<"\n==========================================";
emp[i].putData();
cout<<"\n==========================================";
}
getch();
return 0;
}
No comments:
Post a Comment