Topic: Programming in C++
What problem in C++ multiple inheritance is resolved by declaring base classes with virtual public Base?
- A. Slicing problem
- B. Dangling pointer generation
- C. Stack exhaustion
- D. Diamond problem
Answer: D. Diamond problem
Explanation: The 'Diamond Problem' occurs in multiple inheritance when a class inherits from two classes that both share a common base class, causing ambiguity and duplication of the base class members. Using `virtual` inheritance (`virtual public Base`) ensures only a single shared instance of the base class is inherited by the derived class.