[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

C++ Programming :: Objects and Classes - Discussion

Home > C++ Programming > Objects and Classes > MCQs Questions Discussion

84 / 41

Choose the correct option.

What is the use of virtual base class in c++

AMultiple lines between derived classes.

BMultiple lines between base classes.

Cinheritance

DNone of these

Answer: Option (Login/Signup)

Show Explanation

Virtual keyword, when assigned to base class while deriving a new class helps to prevent having multiple instances of the base class. so that there will be no ambiguity.

Lets say class b and class c are derived classes of class a and class a has a member function void foo(). Now, if we derive class d from both class b and class c, then the statement d.foo() creates ambiguity between the versions of class b and class c. To avoid this behavior, we must use Virtual keyword before the base class ('a') while deriving the classes b and c.

Asked In :: Wipro Societe Generale

Post Your Answer Here:     

Reply    
Rate This: +0 -0
    Report


Report Error

Please Login First Click Here