Virtual Base Classes
This ambiguity can be resolved if the class derived have only one copy of the class base. This can be done by making the base class a virtual class. This keyword makes the two classes share a one copy of their base class . It can be done as follows :
class base
{
:
:
};
class Aclass : virtual public base
{
:
:
};
class Bclass : virtual public base
{
:
:
};
class derived : public Aclass, public Bclass
{
:
:
};
This will resolve the ambiguity included.