Multiple inheritance is a feature of some object-oriented computer programming languages in which a class can inherit characteristics and features from more than one superclass. It is distinct to single inheritance, where a class may only inherit from one particular superclass.
Languages that support multiple inheritance include C++, Common Lisp via the Common Lisp Object System, Perl and Python.
Multiple inheritance has been a touchy issue for many years, with opponents pointing to its increased complexity and ambiguity in situations such as the "diamond problem", where it may be ambiguous as to which superclass a particular feature is inherited from if more than one superclass implements said feature. This can be addressed in various ways, including using virtual inheritance.
Details
In object-oriented programming (OOP), inheritance describes a relationship between two types, or classes, of objects in which one is said to be a subtype or child of the other. The child inherits features of the parent, allowing for shared functionality. For example, one might create a variable class Mammal with features such as eating, reproducing, etc.; then define a subtype Cat that inherits those features without having to explicitly program them, while adding new features like chasing mice.
Multiple inheritance allows programmers to use more than one totally orthogonal hierarchy simultaneously, such as allowing Cat to inherit from Cartoon character and Pet and Mammal and access features from within all of those classes. Lack of multiple inheritance often results in a very awkwardly mixed hierarchy, or forces functionality to be rewritten in more than one place, with attendant maintenance problems.
Implementations
Languages that support multiple inheritance include: C++, Common Lisp (via Common Lisp Object System (CLOS)), EuLisp (via The EuLisp Object System TELOS), Curl, Dylan, Eiffel, Logtalk, Object REXX, Scala (via use of mixin classes), OCaml, Perl, Perl 6, Python, and Tcl (via Incremental Tcl (Incr Tcl)).[2]
Some object-oriented languages, such as C#, Java, and Ruby implement single inheritance, although protocols, or interfaces, provide some of the functionality of true multiple inheritance.
PHP uses traits classes to inherit multiple functions.
Languages that support multiple inheritance include C++, Common Lisp via the Common Lisp Object System, Perl and Python.
Multiple inheritance has been a touchy issue for many years, with opponents pointing to its increased complexity and ambiguity in situations such as the "diamond problem", where it may be ambiguous as to which superclass a particular feature is inherited from if more than one superclass implements said feature. This can be addressed in various ways, including using virtual inheritance.
Details
In object-oriented programming (OOP), inheritance describes a relationship between two types, or classes, of objects in which one is said to be a subtype or child of the other. The child inherits features of the parent, allowing for shared functionality. For example, one might create a variable class Mammal with features such as eating, reproducing, etc.; then define a subtype Cat that inherits those features without having to explicitly program them, while adding new features like chasing mice.
Multiple inheritance allows programmers to use more than one totally orthogonal hierarchy simultaneously, such as allowing Cat to inherit from Cartoon character and Pet and Mammal and access features from within all of those classes. Lack of multiple inheritance often results in a very awkwardly mixed hierarchy, or forces functionality to be rewritten in more than one place, with attendant maintenance problems.
Implementations
Languages that support multiple inheritance include: C++, Common Lisp (via Common Lisp Object System (CLOS)), EuLisp (via The EuLisp Object System TELOS), Curl, Dylan, Eiffel, Logtalk, Object REXX, Scala (via use of mixin classes), OCaml, Perl, Perl 6, Python, and Tcl (via Incremental Tcl (Incr Tcl)).[2]
Some object-oriented languages, such as C#, Java, and Ruby implement single inheritance, although protocols, or interfaces, provide some of the functionality of true multiple inheritance.
PHP uses traits classes to inherit multiple functions.
Comments
Post a Comment
https://gengwg.blogspot.com/