#include<iostream>
using namespace std;
class employee
{
public:
char name[50],empid[10];
double sal,gs,ns;
virtual void cal_sal()=0;
};
class manager:public employee
{
double da,hra;
public:
manager()
{
cout<<"\nenter name,empid,sal\n";
cin>>name>>empid>>sal;
}
void cal_sal()
{
da=sal*0.10;
hra=sal*0.20;
gs=sal+da+hra;
ns=gs;
cout<<"\ncontents of manager\n";
cout<<"\nname\tempid\tsal\tda\thra\tgs\tns\n";
cout<<"\n"<<name<<"\t"<<empid<<"\t"<<sal<<"\t"<<da<<"\t"<<hra<<"\t"<<gs<<"\t"<<ns<<"\n";
}
};
class salesman:public employee
{
double da,hra,ta;
public:
salesman()
{
cout<<"\nenter name,empid,sal\n";
cin>>name>>empid>>sal;
}
void cal_sal()
{
da=sal*0.30;
hra=sal*0.40;
ta=sal*0.20;
gs=sal+da+hra;
ns=gs-ta;
cout<<"\ncontents of salesman\n";
cout<<"\nname\tempid\tsal\tda\thra\tta\tgs\tns\n";
cout<<"\n"<<name<<"\t"<<empid<<"\t"<<sal<<"\t"<<da<<"\t"<<hra<<"\t"<<ta<<"\t"<<gs<<"\t"<<ns<<"\n";
}
};
int main()
{
system("clear");
employee *bptr[3];
manager m1;
salesman s1;
bptr[0]=&m1;
bptr[0]->cal_sal();
bptr[1]=&s1;
bptr[1]->cal_sal();
return 0;
}
using namespace std;
class employee
{
public:
char name[50],empid[10];
double sal,gs,ns;
virtual void cal_sal()=0;
};
class manager:public employee
{
double da,hra;
public:
manager()
{
cout<<"\nenter name,empid,sal\n";
cin>>name>>empid>>sal;
}
void cal_sal()
{
da=sal*0.10;
hra=sal*0.20;
gs=sal+da+hra;
ns=gs;
cout<<"\ncontents of manager\n";
cout<<"\nname\tempid\tsal\tda\thra\tgs\tns\n";
cout<<"\n"<<name<<"\t"<<empid<<"\t"<<sal<<"\t"<<da<<"\t"<<hra<<"\t"<<gs<<"\t"<<ns<<"\n";
}
};
class salesman:public employee
{
double da,hra,ta;
public:
salesman()
{
cout<<"\nenter name,empid,sal\n";
cin>>name>>empid>>sal;
}
void cal_sal()
{
da=sal*0.30;
hra=sal*0.40;
ta=sal*0.20;
gs=sal+da+hra;
ns=gs-ta;
cout<<"\ncontents of salesman\n";
cout<<"\nname\tempid\tsal\tda\thra\tta\tgs\tns\n";
cout<<"\n"<<name<<"\t"<<empid<<"\t"<<sal<<"\t"<<da<<"\t"<<hra<<"\t"<<ta<<"\t"<<gs<<"\t"<<ns<<"\n";
}
};
int main()
{
system("clear");
employee *bptr[3];
manager m1;
salesman s1;
bptr[0]=&m1;
bptr[0]->cal_sal();
bptr[1]=&s1;
bptr[1]->cal_sal();
return 0;
}
No comments:
Post a Comment