34,333
edits
Changes
→Inheritance, Classes and Subclasses
== Inheritance, Classes and Subclasses ==
The concept of inheritance brings something of a real-world view to programming. It allows a class to be defined which that has a number certain set of characteristics (such as methods and instance variables) and then other classes to be created which are derived from that class. The derived class inherits all of the features of the parent class and typically then adds some features of its own.
By deriving classes we create what is often referred to as a ''class hierarchy''. The class at the top of the hierarchy is known as the ''base class'' or ''root class'' and the derived classes as ''subclasses'' or ''child classes''. Any number of subclasses may be derived from a class. The class from which a subclass is derived is called the ''parent class''.