Entry
C#: Class: Inheritance: What is inheritance?
Sep 29th, 2003 09:55
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 27 September 2003 - 06:17 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 (e.g. reuse, creating classification, creating hierarchy,
...).
---
---
There are times when you need to define a class based on another -
existing - class.
---
For example you may need to define a class to represent a Savings
account for a bank.
---
But we may already have a class named 'BankAccount' which has most of
the
functionality you need.
---
Instead of creating a class from scratch you can define your class
based on the existing 'BankAccount' class.
---
Your new class inherits all the public methods, properties and fields
of the existing class, while adding to them all the methods, properties
and fields it defines.
---
The class you are starting from is called the 'base' class.
---
Your new class is called a 'derived' class.
---
Each 'base' class can have many 'derived' classes.
---
And each 'derived' class - in turn - can be extended further creating a
hierarchy of class definitions.
---
It is important to know that each 'derived' class can only have one
'base' class.
---
That is, you can inherit from only a single, parent class.
---
[Internet: source: http://www.joegrip.com]
---
---
Note: here 'base' class can also be read as 'parent' class and
'derived' class can also be read as 'child' class.
---
So the hierarchy that is created is basically a 'tree' (and not
a 'graph).
---
---
Internet: see also:
C#: Class: Inheritance: Create: Simple: Can you give an example of
inheritance?
http://www.faqts.com/knowledge_base/view.phtml/aid/24889/fid/791
C++: Class: Inheritance: What is inheritance?
http://www.faqts.com/knowledge_base/view.phtml/aid/24866
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
----------------------------------------------------------------------