Intro about Inheritance in C++

Inheritance Definition

                    "Derive quality and characteristics from parents or ancestors. Like you inherit features of your parents."
  • Example: She had inherited the beauty of her mother.
                  Inheritance in Object Oriented Programming can be described as a process of creating new classes from existing classes. New classes inherit some of the properties and behavior of the existing classes.
                  An existing class that is "parent" of a new class is called a base class.  New class that inherits properties of the base class is called a derived class.
                  Inheritance is a technique of code reuse. It also provides possibility to extend existing classes by creating derived classes.

Inheritance Syntax :

The basic syntax of inheritance is:
class DerivedClass : accessSpecifier BaseClass
Here, describe the different type of inheritance.

Types of Inheritance :

           There are different types of inheritance:
-Single Inheritance
-Multiple Inheritance
-Multilevel Inheritance
-Hierarchical Inheritance
-Hybrid (Virtual) Inheritance

- Single Inheritance :

                  Single inheritance represents a form of inheritance when there is only one base class and one derived class. 

For example, a class describes a Person:

1.1  Simple Inheritance

- Multiple Inheritance :

               Multiple inheritance represents a kind of inheritance when a derived class inherits properties of multiple classes. 

For example, there are three classes A, B and C and derived class is D as shown below:

1.2  Multiple Inheritance

- Multilevel Inheritance :

                  Multilevel inheritance represents a type of inheritance when a Derived class is a base class for another class. 

                    In other words, deriving a class from a derived class is known as multi-level inheritance. 
Simple multi-level inheritance is shown in below image where Class A is a parent of Class B and Class B is a parent of Class C.

1.3 Multiple Inheritance

- Hybrid Inheritance (also known as Virtual Inheritance)

                Combination of Multi-level and Hierarchical inheritance will give you Hybrid inheritance. 
1.4  Hybrid Inheritance

- Hierarchical Inheritance

                 If one or more classes are derived from one class then it is called hierarchical inheritance.

1.5 Hierarchical Inheritance