Inheritance
m |
m |
||
(One intermediate revision by one user not shown) | |||
Line 1: | Line 1: | ||
Inheritance is an OO concept that is designed to support code reuse by allowing classes within a program to extend or change the functionality of existing classes. | Inheritance is an OO concept that is designed to support code reuse by allowing classes within a program to extend or change the functionality of existing classes. | ||
[[Image:Inheritance.jpg|frame|Example inheritance hierarchy]] | [[Image:Inheritance.jpg|frame|Example inheritance hierarchy]] | ||
− | The '''Parent''' or '''Super Class''' is inherited from by the '''Subclass'''. All the public behaviour of the super class can be accessed through an instance of the subclass. In the example hierarchy class ''C'' also has the behaviour of ''duck'' and ''dive'' inherited from class ''A''. | + | The '''Parent''' or '''[[Superclass|Super Class]]''' is inherited from by the '''[[Subclass]]'''. All the public behaviour of the super class can be accessed through an instance of the subclass. In the example hierarchy class ''C'' also has the behaviour of ''duck'' and ''dive'' inherited from class ''A''. |
The process of '''Specialisation''' | The process of '''Specialisation''' | ||
Line 9: | Line 9: | ||
* [[Superclass]] | * [[Superclass]] | ||
* [[Subclass]] | * [[Subclass]] | ||
+ | * [[Class versus Object]] | ||
{{Nomenclature}} | {{Nomenclature}} | ||
[[Category: Nomenclature]] | [[Category: Nomenclature]] |
Latest revision as of 22:19, 16 September 2009
Inheritance is an OO concept that is designed to support code reuse by allowing classes within a program to extend or change the functionality of existing classes.
The Parent or Super Class is inherited from by the Subclass. All the public behaviour of the super class can be accessed through an instance of the subclass. In the example hierarchy class C also has the behaviour of duck and dive inherited from class A.
The process of Specialisation allows the subclass to add extra functionality by adding new methods. it also allows the subclass to change the functionality of inherited behaviour by overriding existing inherited methods with new ones. This is one form of polymorphism. In the example class B overrides the dive behaviour inherited from class A with its own 'dive method.
See Also
Nomenclature | |
---|---|
Techniques: Abstraction | Aggregation versus Composition | Association versus Dependency | Coupling | Encapsulation | Information hiding | Inheritance | Multiple Inheritance | Overloading | Polymorphism
Features: Abstract class | Class versus Object | Component versus Module | Instance | Interface | Method | Package versus Namespace | Superclass | Subclass |