Everything You Wanted to Know About Forms Inheritance in VB.Net - Concept of Inheritance (Page 2 of 6 )
OO Programmers should full understand the concept of inheritance. This section is especially for the non-OO-based programmers, so the experienced OO programmers can skip this section.
Definition (Inheritance) Inheritance is the mechanism which allows class A to inherit properties of class B. We say “A inherits from B”. Thus, objects of class A have access to attributes and methods of class B without the need to redefine them. The following definition defines two terms with which we are able to refer to participating classes when they use inheritance.
Definition (Superclass/Subclass) If class A inherits from class B, then B is called a superclass of A. A is called a subclass of B. Objects of a subclass can be used where objects of the corresponding superclass are expected. This is due to the fact that objects of the subclass share the same behavior as objects of the superclass.
In the literature you may also find other terms for “superclass” and “subclass”. Superclasses are also called parent classes. Subclasses may also be called child classes or just derived classes. Of course, you can again inherit from a subclass, making this class the superclass of the new subclass. This leads to a hierarchy of superclass/subclass relationships. If you draw this hierarchy you get an inheritance graph.
A common drawing scheme is to use arrowed lines to indicate the inheritance relationship between two classes or objects. In our examples we have used “inherits-from”. Consequently, the arrowed line starts from the subclass towards the superclass.
In the literature you also find illustrations where the arrowed lines are used just the other way around. The direction, in which the arrowed line is used, depends on how the corresponding author has decided to understand it.