Matches in DBpedia 2014 for { <http://dbpedia.org/resource/Virtual_inheritance> ?p ?o. }
Showing items 1 to 19 of
19
with 100 items per page.
- Virtual_inheritance abstract "For inheritance of virtual functions, see virtual function.Virtual inheritance is a technique used in object-oriented programming, where a particular base class in an inheritance hierarchy is declared to share its member data instances with any other inclusions of that same base in further derived classes. For example, if class A is normally (non-virtually) derived from class X (assumed to contain data members), and class B likewise, and class C inherits from both classes A and B, it will contain two sets of the data members associated with class X (accessible independently, often with suitable disambiguating qualifiers). But if class A is virtually derived from class X instead, then objects of class C will contain only one set of the data members from class X. The best-known language that implements this feature is C++.This feature is most useful for multiple inheritance, as it makes the virtual base a common subobject for the deriving class and all classes that are derived from it. This can be used to avoid the problem of ambiguous hierarchy composition (known as the "diamond problem") by clarifying ambiguity over which ancestor class to use, as from the perspective of the deriving class (C in the example above) the virtual base (X) acts as though it were the direct base class of C, not a class derived indirectly through its base (A).It is used when inheritance represents restriction of a set rather than composition of parts. In C++, a base class intended to be common throughout the hierarchy is denoted as virtual with the virtual keyword.Consider the following class hierarchy.As declared above, a call to bat.eat is ambiguous because there are two Animal (indirect) base classes in Bat, so any Bat object has two different Animal base class subobjects. So an attempt to directly bind a reference to the Animal subobject of a Bat object would fail, since the binding is inherently ambiguous:To disambiguate, one would have to explicitly convert bat to either base class subobject: In order to call eat, the same disambiguation is needed: static_cast<Mammal&>(bat).eat or static_cast<WingedAnimal&>(bat).eat.In this case, the double inheritance of Animal is probably unwanted, as we want to model that the relation (Bat is an Animal) exists only once; that a Bat is a Mammal and is a WingedAnimal does not imply that it is an Animal twice: an Animal base class corresponds to a contract that Bat implements (the "is a" relationship above really means "implements the requirements of"), and a Bat only implements the Animal contract once. The real world meaning of "is a only once" is that Bat should have only one way of implementing eat, not two different ways, depending on whether the Mammal view of the Bat is eating, or the WingedAnimal view of the Bat. (In the first code example we see that eat is not overridden in either Mammal or WingedAnimal, so the two Animal subobjects will actually behave the same, but this is just a degenerate case, and that does not make a difference from the C++ point of view.)This situation is sometimes referred to as diamond inheritance (see Diamond problem) because the inheritance diagram is in the shape of a diamond. Virtual inheritance can help to solve this problem.".
- Virtual_inheritance wikiPageID "1907963".
- Virtual_inheritance wikiPageRevisionID "593606246".
- Virtual_inheritance hasPhotoCollection Virtual_inheritance.
- Virtual_inheritance subject Category:C++.
- Virtual_inheritance subject Category:Class_(computer_programming).
- Virtual_inheritance comment "For inheritance of virtual functions, see virtual function.Virtual inheritance is a technique used in object-oriented programming, where a particular base class in an inheritance hierarchy is declared to share its member data instances with any other inclusions of that same base in further derived classes.".
- Virtual_inheritance label "Herencia virtual".
- Virtual_inheritance label "Virtual inheritance".
- Virtual_inheritance label "Виртуальное наследование".
- Virtual_inheritance label "仮想継承".
- Virtual_inheritance label "虚继承".
- Virtual_inheritance sameAs Herencia_virtual.
- Virtual_inheritance sameAs 仮想継承.
- Virtual_inheritance sameAs m.065cly.
- Virtual_inheritance sameAs Q1526910.
- Virtual_inheritance sameAs Q1526910.
- Virtual_inheritance wasDerivedFrom Virtual_inheritance?oldid=593606246.
- Virtual_inheritance isPrimaryTopicOf Virtual_inheritance.