← Quiz: Multiple Inheritance and the Diamond Problem: all 10 questions
Quiz: Multiple Inheritance and the Diamond Problem · Question 5 of 10
Where is the virtual keyword written to fix the diamond Device → Printer/Scanner → Copier?
Where is the virtual keyword written to fix the diamond Device → Printer/Scanner → Copier?
- A.class Copier : virtual public Printer, virtual public Scanner
- B.class Printer : virtual public Device and class Scanner : virtual public Device
- C.virtual class Device
- D.On Device's constructor
Answer & explanation
Correct answer: class Printer : virtual public Device and class Scanner : virtual public Device
The middle classes declare Device as a virtual base so that they share it.
Can you get the rest right without peeking?
Take the timed Quiz: Multiple Inheritance and the Diamond Problem quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →