Inheritance is the system in object oriented programming that allows objects to support operations defined by anterior types without having to provide their own definition. It is the major vector for polymorphism in object-oriented programming.
Inheritance is the main method by which object-oriented systems provide polymorphism.
Where a class Sub
inherits from another class (or other object, as in Self or JavaScript) Base
, Sub
will share some or all of the operations (possibly including data access and storage) provided by Base
. It is usually the case that Sub
will receive at least the full public interface of Base
in order to allow any object of type Sub
to stand in place of an object of type Base
in any code written to work on objects of type Base
(refer to the Liskov Substitution Principle).
This facility is orthogonal to the type of type system used, the function binding regime (whether late or early), whether or not there is a privacy regime, or indeed the evaluation (whether lazy or weak).
Example of inheritance on a UML diagram: