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

Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?

3694


Is sorted c++?

571


What is the latest c++ standard?

673


What is a virtual function in C++?

584


How do you traverse a btree in backward in-order?

616






What are the major differences between C and C++?

607


declare an array of structure where the members of the structure are integer variable float variable integer array char variable access all elements of the structure using dot operator and this pointer operator

1739


Explain the importance of method overloading in C++?

549


Tell me about virtual function

538


What is copy constructor? Can we make copy constructor private in c++?

589


Can comments be nested?

619


Is c++ a software?

722


What is a v-table?

642


Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);

614


What is polymorphism what is it for and how is it used?

570