Monday, 19 November 2012

Multiple Inheritance

In object-oriented programming is multiple inheritance, when a derived class inherits directly from more than one base class. A sequential, multi-heirs will not however referred to as multiple inheritance.

Multiple Inheritance
An application example is the modeling of an amphibious vehicle that is both the attributes of a land vehicle which also inherits from watercraft. Thus have both an amphibious vehicle wheels numbers and a draft.

Few programming languages ​​offer the possibility of multiple-class inheritance, for example, C + +, CLOS, Eiffel, Perl and Python. As an objection to multiple-class inheritance is often referred to, that they can make the design unnecessarily complicated and opaque. It can therefore be ambiguity in the context of the Diamond problem. In some programming languages​​, such as Oberon and its further development, was therefore deliberately left out the possibility of multiple implementation inheritance, which can be compensated by the use of dual class.

However, multiple interface inheritance is straightforward. In Java, Object Pascal (Delphi), C # and VB.NET, a class can inherit any number of interfaces. Thus committed this class to provide the interface methods available and thus makes something similar to the is-a relationship, the ratio is as-relationship-forth.

With simple class inheritance and multiple interface inheritance, most requirements for a software design can be realized, without the disadvantages of full multiple inheritance to have to accept.

No comments:

Post a Comment