 Hello friends, I am Sanjay Gupta. In this video I am going to demonstrate you how you can implement hierarchical inheritance in C++. Before starting, you can note my information. You can follow my YouTube channel that is sanjaygupta underscore tech school. You can download my app Techimus based on programming languages which is available on Google Play. Now coming on to the topic. In this example, I am going to demonstrate you the implementation of hierarchical inheritance. So hierarchical inheritance contains one base class and more than one derived classes. So in this example, I am considering person class as base class and student and employee classes are derived classes. So I have included a header file IO stream. Then I have used a namespace that is STD. Then base class person is implemented which is having two attributes ID and name. Then read function is implemented inside read function. Scene and see out statements are defined which will receive ID and name from user. Then print function is implemented which will display ID and name on console using see out statement. Then I have terminated person class. After termination of person class, I have implemented student class. So here student class is derived class for person class. Person is treated as base class. In student class, roll number and branch two attributes are declared. Inside read function of student class, first I have called read function of person class using a class name person and scope resolution operator. Then roll number and branch are received using see in and see out statements. Then in print function of student class, print function of person class is called first and then roll number and branch of student will be displayed using see out statement. So this is the definition of student class which is having two functions read and print and student class is working as derived class for person class. Then third class which is employee is implemented. Employee is also a derived class for person class. So person is base class which is having two derived classes student and employee. In this class designation and salary both are attributes. Then read function is implemented. This read function is calling read function of person class first and then it is reading designation and salary of employee. After that print function is implemented. Inside print function definition print of person class is called first and then designation and salary of employee is displayed using see out statement. So you can see three classes are implemented. First is person, second one is salary and third one is employee. Sorry, second one is student and third one is employee. So here in main function I have to create object of student class as well as employee class. So you can see for student class I have created an object as which is calling read and print function. Then I have created object E for employee class which is also calling read and print function. So these student and employee class objects are calling their read and print functions and their read and print functions are internally calling read and print functions of person class. So this is the complete implementation of hierarchical inheritance in C++. Now I am going to execute this code. You can see it is asking for details of student. First ID I am entering one. It is asking for name. I am entering Sanjay. It is asking for roll number. I am entering 22 and then branch. I am entering EC. It is showing the result for student ID, name, roll number and branch. Then again it is asking for ID for employee. I am entering one. It is asking for name. I have entered Vikas designation. I am entering manager salary. I am entering 50,000. You can see it is showing ID, name, designation and salary which I have entered. So this way hierarchical inheritance is working in C++. So first class is person which is base class. Second class is student which is derived class. Third class is employee which is also derived class. Then objects of derived classes are created in main function and then read and print functions are called. This is the complete implementation of hierarchical inheritance. I hope you have understood the concept well. If you want to watch more programming related videos you can follow my YouTube channel that is Sanjay Gupta underscore Tech School. You can download my app based on programming languages that is TechMS which is available on Google Play. Thank you for watching this video.