Several classes may exsist. Each may have data member or member
functions
with the same name. This situation may give rise to ambiguitites
#includeGo Backclass Base_1 { protected: int data_x; public: Base_1(){ cout << "In Base_1 constructor" << endl; } void Display() { cout << "Call Base_1 Display(): Base_1 data_x is:" << data_x << endl; } ~Base_1(){ cout << "Base_1 destructor called" << endl; } }; class Base_2 { protected: int data_x; public: Base_2(){ cout << "In Base_2 constructor" << endl; } void Display() { cout << "Call Base_2 Display(): Base_2 data_x is: " << data_x << endl << endl; } ~Base_2(){ cout << "Base_2 destructor called" << endl; } }; class Derived: public Base_1, public Base_2 { public: Derived(int i){ cout << "In Derived constructor "; // -------> data_x = i; cout << "data_x is: " << data_x << endl << endl; } ~Derived(){ cout << "Derived destructor called" << endl; } }; /* --------------Configuration: MultipleInheritanceII - Win32 Debug-------------- Compiling... MultipleInheritanceII.cpp D:\Cop3338 fall 98\Multiple Inheritance 2\MultipleInheritanceII.cpp(34) : error C2385: 'Derived::data_x' is ambiguous D:\Cop3338 fall 98\Multiple Inheritance 2\MultipleInheritanceII.cpp(34) : warning C4385: could be the 'data_x' in base 'Base_1' of class 'Derived' D:\Cop3338 fall 98\Multiple Inheritance 2\MultipleInheritanceII.cpp(34) : warning C4385: or the 'data_x' in base 'Base_2' of class 'Derived' Error executing cl.exe. MultipleInheritanceII.obj - 1 error(s), 2 warning(s) */ void main() { Derived D(100); // --> D.Display(); } /* -------------Configuration: MultipleInheritanceII - Win32 Debug---------------- Compiling... MultipleInheritanceII.cpp D:\Cop3338 fall 98\Multiple Inheritance 2\MultipleInheritanceII.cpp(60) : error C2385: 'Derived::Display' is ambiguous D:\Cop3338 fall 98\Multiple Inheritance 2\MultipleInheritanceII.cpp(60) : warning C4385: could be the 'Display' in base 'Base_1' of class 'Derived' D:\Cop3338 fall 98\Multiple Inheritance 2\MultipleInheritanceII.cpp(60) : warning C4385: or the 'Display' in base 'Base_2' of class 'Derived' Error executing cl.exe. MultipleInheritanceII.exe - 1 error(s), 2 warning(s) */