Multiple inheritance is a feature of some object-oriented computer programming languages in which an object or class can inherit characteristics and features from more than one parent object or parent class.
Example
#include<iostream> #include<conio.h> using namespace std ; class employee { protected : string idno , name , designation ; public : void input () { cout<<"Enter Name \n"; getline(cin,name); cout<<"Enter ID \n"; getline(cin,idno); cout<<"Enter Designation \n"; getline(cin,designation); } void show () { cout<<" Name is :"<<name<<endl; cout<<"ID is :"<<idno<<endl; cout<<"Designation is :"<<designation<<endl; } employee() { idno=name=designation=" "; } }; class salary : public employee { protected : float Basic_pay ,Human_Resource_allowance ,Dearness_allowance ,Profitability_fund ; public : void calculate_salary(){ cout<<"Enter Basic Pay \n"; cin>>Basic_pay; cout<<"Enter Human Resource Allowance\n"; cin>>Human_Resource_allowance; cout<<"Enter Dearness Allowance\n"; cin>>Dearness_allowance; cout<<"Enter Profitability Fund\n"; cin>>Profitability_fund; float salary ; salary = Basic_pay+Human_Resource_allowance+Dearness_allowance+Profitability_fund; show(); cout<<"Dear "<<name <<" Your Total Salary is :"<<salary ; cout<<endl; } }; class bouns : public salary { protected : int bouns ; public : void boun_salary () { bouns=1300; } void total_salary () { float ts; ts=bouns+salary; cout<<"Dear"<<name<<"Your Salary With Bouns :"<<ts; } }; class transport : public employee { protected : float transport; public : void transport_charges() { float ts; cout<<"Enter you transport chagers\n"; cin>>transport; ts=salary-transport; cout<<"After Deductions of transport chagers your salary is : "<<ts; cout<<"/n"; } }; int main () { salary em1,em2,em3; em1.input(); em1.calculate_salary(); em1.show(); em2.input(); em2.calculate_salary(); em2.show(); em3.input(); em3.calculate_salary(); em3.show(); return 0 ; }
Post A Comment:
0 comments: