C++ Class Inheritance diamond-shaped multiple inheritance

Description

C++ Class Inheritance diamond-shaped multiple inheritance

#include <iostream>
using namespace std;
class A//from  w  ww. ja  v a 2 s  . co  m
{
   public:
   virtual void func();
};
class B : public A
{  };
class C : public A
{  };
class D : public B, public C
{  };
int main()
{
   D objD;
   objD.func();  //ambiguous: won't compile
   return 0;
}



PreviousNext

Related