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 an html tag?

1145


the first character in the variable name must be an a) special symbol b) number c) alphabet

1091


What is enum class in c++?

1245


What is the benefit of c++?

1129


Differentiate between late binding and early binding.

1272


What are the types of array in c++?

1159


Will c++ be replaced?

1041


How should a contructor handle a failure?

1183


What you know about structures in C++?

1074


What is a manipulative person?

1010


What do you understand by zombie objects in c++?

1095


How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?

1032


How the memory management in vectors are being done. What happens when the heap memory is full, and how do you handle it ?

2310


What is the use of turbo c++?

1048


What is scope resolution operator in c++ with example?

1033