1 Answers
Code:
#include <iostream>
using namespace std;
class grandparent
{
public:
void gpfunc()
{
cout<<“gp class function\n”;
}
};
class parent1 : public virtual grandparent
{
public:
void p1func()
{
cout<<“p1 class function\n”;
}
};
class parent2 : public virtual grandparent
{
public:
void p2func()
{
cout<<“p2 class function\n”;
}
};
class child : public parent1, public parent2
{
public:
void chfunc()
{
cout<<“child class function\n”;
}
};
int main()
{
child c;
c.gpfunc();
c.p1func();
c.p2func();
c.chfunc();
return 0;
}