//creat a super class and inhrit it's features to it's sub class plus some additional
//characteristics to sub classes
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class employee
{
protected:
int n;
char name[20];
public:
void getdata()
{
cout<<"enter name ";
gets(name);
cout<<"enter phone no ";
cin>>n;
}
void show()
{
cout<<"name: "<<name<<endl;
cout<<"phone no: "<<n<<endl;
}
};
class perm:public employee
{
protected:
int l,a;
public:
void getdata1()
{cout<<"enter length of services: ";
cin>>l;
cout<<"enter alounces: ";
cin>>a;
}
void show1()
{
cout<<"length of service: "<<l<<" years "<<endl;
cout<<"alounces: "<<a<<endl;
}
};
class contract:public employee
{
protected:
int d,s;
public:
void getdata2()
{
cout<<"duration of contract: ";
cin>>d;
cout<<"salary ";
cin>>s;
}
void show2()
{
cout<<"duration of contract: "<<d<<endl;
cout<<"salary: "<<s<<endl;
}
};
class daily:public employee
{
protected:
int q,w;
public:
void getdata3()
{
cout<<"enter daily pay: ";
cin>>q;
cout<<"working time ";
cin>>w;
}
void show3()
{
cout<<"daily pay: "<<q<<endl;
cout<<"working time: "<<w<<endl;
}
};
void main()
{
perm p;
contract c;
daily d;
p.getdata();
p.getdata1();
cout<<"For permanent employee \n\n";
p.show();
p.show1();
c.getdata();
c.getdata2();
cout<<"\n\nFor contract employee \n\n";
c.show();
c.show2();
d.getdata();
d.getdata3();
cout<<"For daily bases employee \n\n";
d.show();
d.show3();
getch();
}
0 comments:
Post a Comment