O'Reilly logo

Navigating C++ and Object-Oriented Design by Gail Anderson, Paul Anderson

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

14.5. Multiple Inclusion (Pattern 2)

Multiple inclusion means that derived classes contain more than one instance of the same base class. This is not possible for a direct base class (direct bases must be distinct), but it is possible for some of the direct bases to derive from a common base. Figure 14.5 illustrates an OMT diagram with multiple inclusion base classes. Since both Derived1 and Derived2 have Base1 as their direct base, a D1_D2 object includes two instances of a Base1 part. When multiple inclusion occurs, there is always a potential for ambiguity. Any access to Base1's members from a D1_D2 object must be qualified. Which Base1 object—Derived1's Base1 or Derived2's Base1?

Figure 14.5. Multiple inheritance with multiple inclusion

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