Inheritance is the mechanism whereby specific classes are made from more general ones. The child or derived class inherits all the features of its parent or base class, and is free to add features of its own. In addition, this derived class may be used as the base class of an even more specialized class.
Inheritance, or derivation, provides a clean mechanism whereby common classes can share their common features, rather than having to rewrite them. For example, consider a graph class which is represented by edges and vertices and some (abstract) method of traversal. Next, consider a tree class which is a special form of a graph. We can simply derive tree from graph and the tree class automatically inherits the concept of edges, vertices and traversal from the graph class. We can then restrict how edges and vertices are connected within the tree class so that it represents the true nature of a tree.
Inheritance is supported in C++ by placing the name of the base class after the name of the derived class when the derived class is declared. It should be noted that a standard conversion occurs in C++ when a pointer or reference to a base class is assigned a pointer or reference to a derived class. Examples of inheritance are presented later.