Computer Science, asked by agilandon8761, 1 year ago

Ambiguity in multiple inheritance in c++ in

Answers

Answered by varshneysamyakoxg8tj
0
ambiguity is visible in hybrid inheritance when a base class has 2 derived classes and these 2 derived classes have 1 derived class. a dreaded diamond is formed. the data in top level class has 2 copies created and available in lowest level derived class causes problem of ambiguity.  this can be resolved by virtual derivation 
class A
{
int m;
};
class B: virutal public A
{
};
class C:virtual public A
{
};
class D:public B,public C
{};
problem ambiguity when D gets data from A but resolved by virutally deriving the class
Similar questions