Which of the following statements about virtual base classes is correct ?



Which of the following statements about virtual base classes is correct ?

A. It is used to provide multiple inheritance .

B. It is used to avoid multiple copies of base class in derived class .

C. It is used to allow multiple copies of base class in a derived class.

D. It allows private members of the base class to be inherited in the derived class.

Answer : B. It is used to avoid multiple copies of base class in derived class .


Explanation

  • When two or more objects are derived from a common base class, we can prevent multiple copies of the base class being present in an object derived from those objects by declaring the base class as virtual when it is being inherited such a base class is known as virtual base class.
  • Virtual base classes, used in virtual inheritance, is a way of preventing multiple "instances" of a given class appearing in an inheritance hierarchy when using multiple inheritance.
 Virtual Base Class

Virtual Base Class


Related Searches to Which of the following statements about virtual base classes is correct ?