Take the 2-minute tour ×

This was an exam question.

Write a program demonstrating the use of virtual base classes in multilevel inheritance.

I cannot think of any scenario in which a virtual base class would actually make any difference in the specific case of multilevel inheritance.

The only possible answer to the question i can think of is to show hybrid inheritance(the diamond) which contains multilevel inheritance in it.

Any ideas would be appreciated.

share|improve this question
"I cannot think of any scenario", then "I can think of this one answer"... So, what is the question? –  R. Martinho Fernandes Nov 19 '12 at 13:24
@R.MartinhoFernandes: This was an exam question: Write ... –  David Rodríguez - dribeas Nov 19 '12 at 13:24
The question is a bit confusing, I assume they mean multi-level multiple inheritance - the concept which you describe as the diamond. –  Elemental Nov 19 '12 at 13:27
@Elemental i assumed the same :) –  AsheeshR Nov 19 '12 at 13:37

1 Answer 1

up vote 1 down vote accepted

You answered your question. The answer is the case with the diamond. For the reason and why to use see this question:
In C++, what is a virtual base class?

share|improve this answer

Your Answer


