O'Reilly logo

C++11 for Programmers, Second Edition by Harvey M. Deitel, Abbey Deitel, Paul J. Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compilation Errors Produced When Ambiguity Arises in Diamond Inheritance

Figure 21.13 demonstrates the ambiguity that can occur in diamond inheritance. Class Base (lines 8–12) contains pure virtual function print (line 11). Classes DerivedOne (lines 15–23) and DerivedTwo (lines 26–34) each publicly inherit from Base and override function print. Class DerivedOne and class DerivedTwo each contain a base-class subobject—i.e., the members of class Base in this example.

 1   // Fig. 21.13: fig21_13.cpp 2   // Attempting to polymorphically call a function that is 3   // multiply inherited from two base classes. 4   #include <iostream> 5   using namespace std; 6  7   // class Base definition 8   class Base 9   {10   

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required