← All topics
Quiz: Multiple Inheritance and the Diamond Problem: questions with answers
10 questions, each with the answer and a short explanation.
Take the timed quiz + get a certificate →- Q1. In class Copier : public Printer, public Scanner, which constructor runs first when a Copier is created?
- Q2. What does this print? (code)
- Q3. Both bases of a class define status(). What happens when you call obj.status() without overriding it?
- Q4. What is the diamond problem?
- Q5. Where is the virtual keyword written to fix the diamond Device → Printer/Scanner → Copier?
- Q6. With virtual inheritance, which class constructs the shared virtual base?
- Q7. What does this print? (code)
- Q8. How do you call Scanner's version of status() on a Copier object c?
- Q9. Why are interfaces (classes with only pure virtual functions) safe to combine with multiple inheritance?
- Q10. What is a cost of virtual inheritance?