Hello everyone!! Welcome to help Hindi. In this blog we have explained about the concept of inheritance in C++. After reading all the things you will be able to understand the concept of inheritance, what is the meaning of inheritance in C++ and what are the types of inheritance. So let us discuss it one by one.
What is inheritance?
Before going to the concept of INHERITANCE IN C++, do we need to understand what inheritance is? So, the mechanism of deriving a new class from a previously existing class is called inheritance. The existing class is called the base class and the new class is called the derived class. Inheritance helps us reuse the code and increase code, so also efficiency and organization. It facilitates maintenance and updates. The capability of a class to drive properties and characteristics from another class is called inheritance. Inheritance is a process in which one object acquires all the properties and behaviors of its parents objects automatically.
A – the base class or super class or parent class
B – derived class or subclass or child class
   The class in which the members of another class are inherited is called a derivative class, and the class whose members are inherited is called a base class.
Syntax
Ctrl+O Class derived- class name: visibility meet base class name
{
// Body of the derived Class
}
types of inheritance –
- Single Inheritance
- Multilevel Inheritance
- hierarchical Inheritance
- Multiple Inheritance
- Hybrid Inheritance
- Multipath Inheritance
A derived class with only a base class is called single inheritance. Here are some examples of this inheritance. For example, WAP to create two student & result. Student class contains & name as its data member and result class contains 3 subject marks. Display roll, name, total mark and percentage. We can understand by following image.
class Parent {
// properties and methods of the parent class
}class Child extends Parent {
//properties and methods of the parent class
}
2.Multilevel Inheritance
  Multilevel inheritance is another type of inheritance. It is a feature of object-oriented programming, where a subclass or derived class inherits properties and methods from a parent or base class. which further, it is derived from another parent or base class. So, this creates a chain of inheritance relationships, where it is a derived class that is inherited by a base class which itself inherits from another base class. Here’s an example of multilevel inheritance in Python:
class Grandparent:
def method1(self):
print("This is method1 from Grandparent class")class Parent(Grandparent):
def method2(self):
print("This is method2 from Parent class")class Child(Parent):
def method3(self):
print("This is method3 from Child class")
In the above example, the Grandparent
class represents the base class.
Where, as the Parent
class shows, the derived class that inherits from the class.
And the Child
class shows another derived class that inherits from the class.
It is briefly already in our notes, please go and download it.
3-hierarchical inheritance

So, it is a type of inheritance which is related to object-oriented programming, which means a subclass or child class inherits properties. And the methods from its to super class or parent class. That is itself can also have its own super class.
4-Multiple inheritance

5-HYBRID Inheritance
Hybrid inheritance is another type of inheritance which combines both the features Thai is single inheritance and multiple inheritance in the object-oriented programming. In hybrid inheritance type, a class is derived from two or more base classes. And which is one of the base classes in a combination of two or more classes. This results in a hierarchy of classes that share attributes or we can say methods, whichmakes code to reuse more efficient. This is explained by a diagram which is given by an image.
6-Multipath Inheritance
       Multipath inheritance includes a hybrid of multiple, multi-level, and hierarchical inheritance. A parent class provides their features and functions to the child class, which is known as multipath inheritance. So also a child class derives its functions from several child classes.It can be understood by a given picture.
Â
FAQ
questions
1) Simply what do you mean by the inheritance in c++
Ans- Basically C++  is a feature of inheritance which is based on base class or existing class and the existing class is also known as the base class.
2)How do you define a derived class in C++ ?
Ans- derived class in c++ can be defined as, another class i.e. base class or parent class.