Question 0-8

Define the ``diamond problem'' with multiple inheritance.

Solution

A class can inherit from two classes, each of which inherits from a single shared class, as in the following class declarations.
class A { };
class B : public A { };
class C : public A { };
class D : public B, public C { };
The question of how D instances should incorporate the information defined by A is the diamond problem.

Back to Exam 0