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

Why cstdlib is used in c++?

996


Comment on c++ standard exceptions?

1038


What are the two shift operators and what are their functions?

1035


What size is allocated to the union variable?

1006


How is c++ different from java?

995


What do you mean by “this” pointer?

1031


Explain rethrowing exceptions with an example?

979


Explain how we implement exception handling in c++?

1008


What is using namespace std in cpp?

1065


What sorting algorithm does c++ use?

1080


Why c++ is called oop?

1054


What is c++ coding?

1130


What things would you remember while making an interface?

951


What is operators in c++?

957


What jobs can you get with a c++ certification?

987