What is a virtual base class?

Answer Posted / mukesh kumar

To Remove the ambguity problem in multiple inheritance we
make the base class as vitual that means it will make only
one copy its common data member.

EX: suppose we have a base class A , which have a data
member x as integer.

class b: virtual public A
{
};
class C : virtual public A
{
};
class d: public B,public C
{
}

without making classes A and B as virtual class d had two
copies of x.This will arised ambguity problem.

Is This Answer Correct ?    38 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the differences between list x; & list x();.

608


What is the difference between global variables and local variable

538


In inline " expression passed as argument are evalauated once " while in macro "in some cases expression passed as argument are evaluated more than once " --> i am not getting it plz help to make me understand....

1949


What is the function of I/O library in C++ ?

668


How do I use turbo c++?

550






What is polymorphism and why is it important?

562


What is a lambda function c++?

555


What is an object in c++?

614


What are friend functions in C++?

624


What is overriding in oops?

606


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

5899


Explain virtual inheritance?

685


What is the difference between a constructor and a destructor?

615


Explain overriding.

608


What are the 4 pillars of oop?

674