#include
using namespace std;
class base {
public:
int i;
};
class derived1 : virtual public base {
public:
int j;
};
class derived2 : virtual public base {
public:
int k;
};
/* derived3 inherits both derived1 and derived2.
This time, there is only one copy of base class. */
class derived3 : public derived1, public derived2 {
public:
int sum;
};
int main()
{
derived3 ob;
ob.i = 10; // now unambiguous
return 0;
}