Single Inheritance:

 #include<iostream>

using namespace std;
//base
class A{
int a,b;
public :
void Add(){
cout<<"Input a and b:\n";
cin>>a>>b;
cout<<"Sum="<<(a+b);
}
void Sub(){
cout<<"\nInput a and b:\n";
cin>>a>>b;
cout<<"Sum="<<(a-b);
}
};

//Child
class B:public A
{
public :
void XYZ(){
//
// Add();
}
};

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

B obj;
obj.Add();

return 0;
}

Comments

Popular posts from this blog

Dynamic Memory2

Template

MultiLevel