Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is Virtual Inheritance?

Answer Posted / rama

The duplication of inherited members due to multiple paths can be avoided by making the common base class(ancestor class) as virtual base class..

FOR EXAMPLE

class A //grandparent
{
...
...
};
class B1:virtual public A //parent1
{
...
...
};
class B2:public virtual A //parent2
{
...
...
};
class C :public B1,public B2
{
... //only one copy of A
... //will be inherited
};


When a class is made a virtual base class, it take necessary care to see that only one copy of that class is inherited, regardless of how many inheritance paths exits between the virtual base class and a derived class.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are virtual functions in c++?

1192


What are c++ storage classes?

1113


Which is the best c++ compiler for beginners?

1109


What is the difference between a reference and a pointer?

1128


Is c++ map a hash table?

1041


Why c++ is the best language?

1076


What are the advantages of using friend classes?

1159


What data encapsulation is in c++?

1169


Do the names of parameters have to agree in the prototype, definition, and call to the function?

1035


Is main a class in c++?

1012


How do I run a program in notepad ++?

1127


Do we have to use initialization list in spite of the assignment in constructors?

1011


What is abstraction with real time example?

1164


Define namespace in c++?

1060


What is the most useful programming language?

1063