Technical-Talk banner
Home   About Us   Contact Us

Inheritance

If we have a nice useful chunk of code that forms a nice class which we can create objects as instances of that class we might decide to reuse that class for something a bit different.  We can create a new class that uses all of the old class but with some changes; that new class we call a subclass of the original class.  We don’t cut and paste the old code and change it because then we would have to do maintenance coding in two places.  The subclass inherits the interface as implemented by the original class (baseclass) and then applies its own changes to it as we find necessary. The baseclass (derived class) can be a subclass of another class and it is not uncommon for several generations to exist all derived from the generation above (or below depending on what sort of diagrams you prefer!).  Multiple inheritance is where a subclass has more than one base class - for most mortals this is a short cut to madness and is best avoided.

Google