C++ Class Inheritance Demonstrate ambiguity in multiple inheritance

Description

C++ Class Inheritance Demonstrate ambiguity in multiple inheritance

#include <iostream>
using namespace std;
class A//from  w w  w.  ja  v a 2 s.c  om
{
   public:
   void show()  { cout << "Class A\n"; }
};
class B
{
   public:
   void show()  { cout << "Class B\n"; }
};
class C : public A, public B
{
};
int main()
{
C objC;            //object of class C
// objC.show();       //ambiguous--will not compile
objC.A::show();    //OK
objC.B::show();    //OK
return 0;
}



PreviousNext

Related