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 vectors used for in c++?

1079


Does a derived class inherit or doesn't inherit?

1093


what is the use of void main() in C++ language?

1125


what does the following statement mean? int (*a)[4]

1080


What are the effects after calling the delete this operator ?

1061


What is the c++ programming language used for?

1051


Out of fgets() and gets() which function is safe to use and why?

1193


How can we access protected and private members of a class?

1120


Can you please explain the difference between overloading and overriding?

1108


Which bitwise operator is used to check whether a particular bit is on or off?

1062


What is a driver program?

1112


What is the disadvantage of using a macro?

1127


Explain queue. How it can be implemented?

1161


Are strings mutable in c++?

1139


Are c and c++ similar?

1056