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

Name the implicit member functions of a class.

1085


What is prototype for that c string function?

1145


What are the benefits of c++?

1056


What c++ library is string in?

1060


What's the most powerful programming language?

1041


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

1084


Why c++ is not a pure oop language?

1051


What is new in c++?

1102


What is the limitation of cin while taking input for character array?

2084


Why should we use null or zero in a program?

1046


What is pair in c++?

1073


what is data encapsulation in C++?

1073


What is c++ 11 and c++ 14?

1057


How would you use the functions sin(), pow(), sqrt()?

1190


What is a linked list in c++?

1050