output 2 inheritance
#include <iostream>
using namespace std;
class One{
public:
int F(){return 2;}
virtual int G(){return 3;}
};
class Two: public One{
public:
int F(){return 4;}
int G(){return 5;}
};
class Three: public Two{
public:
int G(){return 7;}
};
int main()
{
One * p1;
One ob1;
Two ob2;
Three ob3;
p1 = &ob1; // base
cout << p1->F() * p1->G(); // = 6
cout << endl;
p1 = &ob2;
cout << p1->F() * p1->G(); // int F() is not virtual therefore
cout << endl; // it take the base function =2*5 =10
p1 = &ob3;
cout << p1->F() * p1->G(); // 2*7 = 14
cout << endl;
Two * p2;
p2 = &ob3;
cout << p2->F() * p2->G(); // 4 * 7 = 28 the f() function from Two
cout << endl; // there is virtual G function...
return 0;
}