The capability of a class to derive properties and characteristics from another class is called inheritance.

Single Inheritance:

If a single class is derived from one base class then it is called single inheritance.

include<iostream>
using namespace std;
//Finding sum of two numbers
class base1
{
    public:
    int x;
    void f1()
    {
        cout << " Enter number " << endl;
        cin >> x;
    }
};
class derived : public base1
{
    int y;
    public:
    void f2()
    {
        cout << " Enter a number " << endl;
        cin >> y;
    }
    void display()
    {
        cout << " Sum =  " << x+y;
    }
};
int main()
{
    derived d;
    d.f1();
    d.f2();
    d.display();
}


Multilevel Inheritance:

Multilevel Inheritance in C++ is the process of deriving a class from another derived class. 
When one class inherits another class it is further inherited by another class. It is known as multi-level inheritance.

#include<iostream>
using namespace std;
//Finding sum of 3 numbers
class base1
{
    public:
    int x;
    void f1()
    {
        cout << " Enter number " << endl;
        cin >> x;
    }
};
class der1 : public base1
{
    public:
    int z;
    void f2()
    {
        cout << " Enter number " << endl;
        cin >> z;
    }
};
class derived2 : public der1
{
    int y;
    public:
    void f3()
    {
        cout << " Enter a number " << endl;
        cin >> y;
    }
    void display()
    {
        cout << " Sum = " << x+y+z;
    }
};
int main()
{
    derived2 d;
    d.f1();
    d.f2();
    d.f3();
    d.display();
}


Multiple Inheritance: 

Multiple Inheritance is the concept of the Inheritance in C++ that allows a child class to inherit properties or behavior from multiple base classes.


#include<iostream>
using namespace std;
class base1
{
    public:
    int x;
    void f1()
    {
        cout << " Enter number " << endl;
        cin >> x;
    }
};
class base2
{
    public:
    int z;
    void f2()
    {
        cout << " Enter number " << endl;
        cin >> z;
    }
};
class derived2 : public base1 , public base2
{
    int y;
    public:
    void display()
    {
        cout << " Sum = " << x + z;
    }
};
int main()
{
    derived2 d;
    d.f1();
    d.f2();
    d.display();
}



Hierarchical Inheritance: 

When several classes are derived from common base class it is called hierarchical inheritance.

#include<iostream>
using namespace std;
//Finding square and cube of number
class base1
{
    public:
    int x;
    void f1()
    {
        cout << " Enter number " << endl;
        cin >> x;
    }
};
class derived1 : public base1
{
    public:
 
    void display1()
    {
        cout << " Square is " << x * x;
    }
};
class derived2 : public base1
{
   
    public:
    void display2()
    {
        cout << " Cube is " << x * x * x;
    }
};
int main()
{
    derived1 d1;
    d1.f1();
    d1.display1();
    derived2 d2;
    d2.f1();
    d2.display2();
}


Hybrid Inheritance: 

When we combine more than one type of inheritance, it is called hybrid inheritance in C++. It is also referred to as a multipath inheritance because many types of inheritances get involved.


Syntax: 

class A 
        // data members and member functions() 
}: 

class B: public A // single inheritance 
        // data members and member functions(); 
}; 
    
class C 
        // data members and member functions(); 
};

class D: public B, public C // multiple inheritance 
{
         // data members and member functions(); 
};