This article is from the Object-Oriented Technology FAQ, by Bob Hathaway email@example.com with numerous contributions by others.
Inheritance provides a natural classification for kinds of objects and allows
for the commonality of objects to be explicitly taken advantage of in modeling
and constructing object systems. Natural means we use concepts,
classification, and generalization to understand and deal with the complexities
of the real world. See the example below using computers.
Inheritance is a relationship between classes where one class is the parent
(base/superclass/ancestor/etc.) class of another. Inheritance provides
programming by extension (as opposed to programming by reinvention
[LaLonde 90]) and can be used as an is-a-kind-of (or is-a) relationship or
for differential programming. Inheritance can also double for assignment
compatibility (see section 2.7).
In delegation languages, such as Self, inheritance is delegation where objects
refer to other objects to respond to messages (environment) and do not
respecify state by default.
Inherited parents can specify various flavors of state. Delegation languages
don't specify new state by default (to do so requires cloning), C-based (C++,
Objective-C, etc.), lisp-based (CLOS, Flavors, Scheme, etc.), and Pascal-based
(Ada95, Modula-3, Object Pascal, etc.) OO languages do, but with multiple-
inheritance can also share parents within a class lattice (CLOS and Eiffel
provide this as a default at the level of slots and features, respectively).
Inheritance also provides for member lookup, or internal environment. Various
schemes exist, for example C++ finds the closest match within a scope but
causes an ambiguity error iff more than one parent has match, CLOS creates
a linear precedence list, Self provides parent priorities, and Eiffel forces
renaming for any parent member conflicts.
Defining inheritance (with a thorough description or denotational semantic
definition, or both) can avoid confusion about which inheritance scheme is
being used (especially in OOD), because inheritance has many variations and
combinations of state and environment (sometimes with complex rules).
Inheritance can also be used for typing, where a type or class can be used to
specify required attributes of a matching object (see sections 2.1, 2.7 and
[Cardelli 85]). It would be more judicious to have discussions on how
inheritance should be defined instead of over what it is, since it has many
existing uses and semantics.
An example of the is-a-kind-of relationship is shown below. Is-a is often
used synonymously, but can be used to show the "object is-a class"
instantiation relationship. In classical OO, inheritance is a relationship
between classes only. In one-level systems, is-a (object instantiation) and
is-a-kind-of (inheritance) are merged into one [Ungar 87, Madsen 93, Sciore
Computer / | \ Mainframe Mini Personal / \ ... / \ Data Proc Scientific PC Workstation