Skip to Content
Navigating C++ and Object-Oriented Design
book

Navigating C++ and Object-Oriented Design

by Paul Anderson, Gail Anderson
October 1997
Intermediate to advanced
800 pages
20h 48m
English
Pearson
Content preview from Navigating C++ and Object-Oriented Design

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
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exploring C++20: The Programmer's Introduction to C++

Exploring C++20: The Programmer's Introduction to C++

Ray Lischner

Publisher Resources

ISBN: 0135327482Purchase book