C++ Inheritance program
#include <iostream>
using namespace std;
class Base{
public :
int x;
int y;
Base(){
cout<<"inside the Base constructor "<<endl;
}
~Base(){
cout<<"inside the destructor "<<endl;
}
void fun(){
cout<<"inside Base fun"<<endl;
}
};
class Derived : public Base {
public:
int i;
int y;
Derived(){
cout<<"inside the derived constructor "<<endl;
}
~Derived(){
cout<<"inside the public constructor "<<endl;
}
void gun(){
cout<<"inside derived gun"<<endl;
}
};
int main()
{
Derived obj;
obj.fun();
}