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

Which is the best c++ compiler?

585


What are formatting flags in ios class?

604


What is a string example?

545


What is abstraction and encapsulation?

569


How one would use switch in a program?

611






What is binary object model?

598


What is null c++?

586


Which operations are permitted on pointers?

566


What is bubble sort c++?

572


Explain the difference between abstract class and interface in c++?

521


What is Coupling?

671


Difference between overloaded functions and overridden functions

576


What is class in oop with example?

616


What do you mean by overloading?

576


What is inheritance write a program to show use of inheritance?

611