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 the purpose of extern storage specifier?

1183


Define basic type of variable used for a different condition in C++?

1101


What is linked list in c++?

1127


What is the c++ programming language used for?

1037


Can malloc be used in c++?

1073


How to declare an array of pointers to integer?

1135


How the keyword struct is different from the keyword class in c++?

1035


What are the advantages of using a pointer? Define the operators that can be used with a pointer.

1027


What are the basic data types used in c++?

1033


Who created c++?

1054


Describe linked list using C++ with an example.

1073


What is a stack c++?

1010


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

1022


Differentiate between realloc() and free().

1040


What do you mean by public protected and private in c++?

1054