Ambiguity in multiple inheritance in c++ in
Answers
Answered by
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
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
Math,
8 months ago
Math,
8 months ago
Political Science,
1 year ago
Science,
1 year ago
English,
1 year ago