With Multiple inheritance Which of the following is a valid constraint or characteristic?
Optym technical mcq question, verified with a worked answer. Free to practise - no sign-up.
With Multiple inheritance**
Which of the following is a valid constraint or characteristic?
Show answer & explanation
Answer: C. C) can include virtual classes
Multiple inheritance in C++ can include virtual base classes to solve the diamond problem (ensuring only a single shared instance of the common base class is inherited).
Step-by-step Derivation:
Step 1: When a class inherits from multiple classes that share a common base, the diamond problem arises.
Step 2: C++ supports virtual inheritance (using virtual base classes) to resolve ambiguities.
Step 3: Thus multiple inheritance can include virtual classes.