//rocord of 10 employees
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class employee
{
private:
char name[40];
char address[40];
char designation[40];
int salary;
static int a;
public:
void getdata()
{
cout<<"enter name "<<endl;
gets(name);
cout<<"enter address "<<endl;
gets(address);
cout<<"enter designation "<<endl;
gets(designation);
cout<<"enter salary "<<endl;
cin>>salary;
}
void displaydata()
{
cout<<"/nname is "<<name<<endl;
cout<<"address is "<<address<<endl;
cout<<"designation is "<<designation<<endl;
cout<<"salary is "<<salary<<endl;
}
employee()
{
a++;
}
int inc()
{
return a;
}
};
int employee::a=0;
void main()
{
employee b1;
cout<<"enter details of employee "<<b1.inc()<<endl<<endl;
b1.getdata();
cout<<"details of employee "<<b1.inc()<<endl<<endl;
b1.displaydata();
employee b2;
cout<<"enter details of employee "<<b2.inc()<<endl<<endl;
b2.getdata();
cout<<"details of employee "<<b2.inc()<<endl<<endl;
b2.displaydata();
employee b3;
cout<<"enter details of employee "<<b3.inc()<<endl<<endl;
b3.getdata();
cout<<"details of employee "<<b3.inc()<<endl<<endl;
b3.displaydata();
//if we declare objects at a single step then the employee
//no remain same that is in this case will be 3
getch();
}
0 comments:
Post a Comment