Simple Inheritance
#include <stdafx.h>
#include <iostream>
#include <string>
using namespace std;
class Class1
{
public:
void display1()
{
cout<< "Display of class1" << endl;
}
};
class Class2:public Class1 // Now Class2 contains all the public members of Class1 through simple inheritance.
{
public:
void display2()
{
cout<< "Display of class2" << endl;
}
};
int main()
{
Class2 c2;
c2.display1();
c2.display2();
return 0;
}
Output:
Display of class1
Display of class2