how to make inheritance program in c++ very easy
Source code
/*
Make by:- skeleton programmer
like & subscribe my channel
*/
#include<iostream>
//#include<conio.h>
using namespace std;
//example of inheritence.
//source code in discription.
class base {
private:
int a;
public:
int b,c;
int setDataA() {
a = 6;
}
int setDataB() {
b = 483;
}
void display() {
c = a + b;
cout<<"The value of a + b \n"<<a<<" + "<<b<<" = "<<c<<endl;
}
};
class derived:public base {
public:
string name = "Like & subscribe";
void display1() {
cout<<name<<endl;
}
};
int main()
{
derived a;
a.display1();
a.setDataA();
a.setDataB();
a.display();
}
Comments
Post a Comment