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

Define pure virtual function?

934


Describe linkages and types of linkages?

943


What are the steps in the development cycle?

1033


Is it possible to have a recursive inline function in c++?

977


What is the use of volatile variable?

1030


In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h

1158


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

978


What is class and structure in c++?

1080


What is vector pair in c++?

1174


Show the declaration for a static member variable.

954


Is there structure in c++?

972


Why should you learn c++?

968


Why do we use iterators?

1012


When can I use a forward declaration?

1033


What is command line arguments in C++? What are its uses? Where we have to use this?

1178