Entry
C++: Class: Inheritance: What is inheritance?
Sep 27th, 2003 09:50
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 27 September 2003 - 05:42 pm ------------------
C++: Class: Inheritance: What is inheritance?
---
The basic idea is that you can 'copy' information (=variables,
functions and procedures) from another class to your current class.
After which you can 'add' or 'insert' extra information (=variables,
functions and procedures) to your current class, to further adapt it to
your needs.
---
---
Inheritance is the process by which one object can aquire the
properties (=variables, functions and procedures) of another object.
---
This is important, because it supports the concept of 'classification'.
---
For example:
A 'Red Delicious' apple is part of the 'classification'
'apple'.
Which in turn is part of the 'fruit' class.
Which in turn is part of the larger class 'food'.
---
Without the use of classifications, each object would have to
explicitely define all of its characteristics.
---
However, through the use of 'classifications', an 'object' need only
define those qualities that make it unique within its class.
---
It is the 'inheritance' mechanism that makes it possible for one
'object' to be a specific instance of a more general case.
---
Inheritance is supported by allowing one class to incorporate another
class into its declaration.
---
Inheritance allows a hierarchy of classes to be built, moving from the
most general to the most specific.
---
The process involves first defining a 'base' class, which
defines those qualities 'common' to all objects derived from that
'base' class.
---
The 'base' class represents the most general description.
---
The classes derived from the 'base' class are usually referred to as
'derived' classes.
---
A 'derived' class includes all features of the generic 'base' class and
then adds qualities specific to the 'derived' class.
---
[book: source: Schildt, Herbert - C++, the complete reference / 2th
edition - McGraw-Hill - ISBN 0078821231 - p. 253, 266 'Inheritance']
---
---
Note: here 'base' class can also be read as 'parent' class and
'derived' class can also be read as 'child' class.
---
---
Internet: see also:
C#: Class: Inheritance: What is inheritance?
http://www.faqts.com/knowledge_base/view.phtml/aid/24870
Delphi: Class: Inheritance: What is inheritance?
http://www.faqts.com/knowledge_base/view.phtml/aid/24869
Java: Class: Inheritance: What is inheritance?
http://www.faqts.com/knowledge_base/view.phtml/aid/24864
----------------------------------------------------------------------