Multiple Inheritance

 #include<iostream>

using namespace std;
//base
class A{

int a,b;
public :
int Add(){
cout<<"Input a and b:\n";
cin>>a>>b;
cout<<"Sum="<<(a+b);
return (a+b);
}
void Sub(){
cout<<"\nInput a and b:\n";
cin>>a>>b;
cout<<"Sum="<<(a-b);
}
};

//Child
class B
{
protected:
int abc=123;
public :
void per(int total){
//Sub 1=50 Mark
//Sub 2=50 Mark
//(total mark *sub_Total)/100;
float p=(float) (total*100)/100;
cout<<"Per="<<p<<"%"<<endl;
cout<<"Change Vaue abc=888"<<endl;
}

void Simple_int(){

}
};


class C :public A,public B
{
public:
void ReadM_Cal_per(){
int total=Add();
per(total);
cout<<abc;

}

};

//===========Main=======
int main(){

C obj;
obj.ReadM_Cal_per();


return 0;
}

Comments

Popular posts from this blog

Dynamic Memory2

Template

MultiLevel