Which problem is commonly solved by virtual inheritance in C++?
Options
- A. Dangling pointer problem
- B. Diamond inheritance problem
- C. Memory leak problem
- D. More than one of the above
- E. None of the above
Quiz Practice:
B. Diamond inheritance problem
Answer: Diamond inheritance problem
The diamond problem occurs when a class inherits from two classes that both inherit from the same base class.
This can cause two copies of the common base class to appear in the final derived class. Virtual inheritance ensures that the common base class is inherited only once.