Ambiguity in the Multiple inheritance
To prevent ambiguity among the derived class and one of the base classes or among the base class themselves, it is better to use the scope resolution operator::
With the data members and methods
#include <iostream.h>
class A
{
char ch;
public:
A(char c)
{
ch=c;
}
void show()
{
cout<<ch;
}
};
class B
{
public:
char ch; B(char c)
{
ch=c;
}
void show()
{
cout<<ch;
}
};
class C:public A, public B
{
public:
char ch;
C(char c1, char c2, char c3):A(c1),B(c2)
{
ch=c3;
}
};
void main()
{
C objc('a','b','c');
// Objc.show(); Error: Field show is ambiguous in C
cout<<"Objc.A::show()=";
objc.A::show();
cout<<"Objc.B::show()=";
objc.B::show();
}