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 / achal ubbott

The concept of virtual inheritance was evolved to avoid
ambiguity/duplication.

e.g.
class base
{
int value;
};
now we do some multiple inheritance
class A:public base {};
class B:public base {};

Now value is member to both the classes A and B.
Lets have a class C that inherits from both A and B.
class C:public A, public B {};

Now should that mean that C have 2 copies of value as its
data member? Yes and this leads to ambiguity.
So do like this

class C:virtual public A,virtual public B {};

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is main function in c++ with example?

1302


What is a stack? How it can be implemented?

1225


What does ios :: app do in c++?

1092


Differentiate between structure and class in c++.

1138


Explain Text Manipulation Routines?

1137


What are enumerations?

1146


Is nan a c++?

1204


Explain some examples of operator overloading?

1163


Is c the same as c++?

1060


how to access grid view row?

2283


When do we run a shell in the unix system? How will you tell which shell you are running?

1025


Why do you use the namespace feature?

1134


Search for: what is pair in c++?

1173


What is the disadvantage of using a macro?

1174


What is ofstream c++?

1150