In object-oriented programming (OOP), inheritance is when an object or class is based on another object or class, using the same implementation. It is a mechanism for code reuse. The relationships of objects or classes through inheritance give rise to a hierarchy.
The most common real world sample to explain inheritance is the geometric shapes object model. Rectangles, Triangles and Circles are geometric shapes. The following figure shows a sample set of geometric figures: