+3 votes
in Class 12 by kratos

What is virtual base class? Give example.

1 Answer

+1 vote
by kratos
 
Best answer

The base class is declared as the virtual base class so that only one copy of its members are inherited by the derived class in a hybrid inheritance. For example, the derived class D derive from the classes B and C whereas both the classes B and C are derived from base class A. Then base class A is inherited twice and to avoid two copies of class A to class D, class A is declared virtual base class.

...