Inheritance: The mechanism of deriving new class from an old/existing class is called inheritance.
OR
Inheritance is the process by which objects of one class acquired the properties of objects of another classes.
Syntax:
class derived-class-name: visibility-mode base-class-name
{
------//
-----// members of derived class
-----//
};
Types of inheritance:
1) Single inheritance: In single inheritance, a derived class is derived from only one base class.
Diagram:
2) Multiple inheritance: In multiple inheritance, derived class is derived from more than one base classes.
Diagram:
3) Hierarchical inheritance: In hierarchical inheritance, more than one derived classes are derived from single class.
Diagram:
4) Multilevel inheritance: In multilevel inheritance, a derived class is derived from a derived class (intermediate base class) which in turn derived from a single base class.
Diagram:
5) Hybrid inheritance: Hybrid inheritance is a combination of single, multiple, multilevel and hierarchical inheritance.
Diagram: