
THE CONCEPT OF INHERITANCE IN C++
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 } https://youtu.be/S1BR0xDdsyM 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 in this inheritance type the properties of one class (base class) want to 2 classes. Â