 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can implement function overriding in C++. Before starting, you can note my information. You can follow my YouTube channel that is sanjaygupta underscore tag school. You can download my Android app that is tag image available on Google Play. Now coming on to the topic, I am going to implement function overriding concept in C++ in this video. So first I am including a header file that is IO stream, then I am using a namespace that is STD. Now I am implementing a class A. Here an attribute is available that is X. Then in public section, I am implementing first function that is read. It will display a message on console that is enter a value that value will be received by X using scene statement. Then I am implementing show function which will display value of X on console. So this is first class that is A. Now I am implementing another class that is B which is inheriting class A. So whenever I am implementing a methods of class B, so class A members are already available inside class B. Now if I implement methods with same name in class B, then the concept of function overriding will be available here. So first I am declaring a variable int y. Then in public section I am implementing read function. It will display a message enter a value and it will receive value inside y variable. And I am implementing again show method which will display value of y on console. So this way I have implemented two classes class A and class B. You can see both the classes are having same method declaration that is void read and void show. So if we recall the concept of function overloading. Function overloading says that we can implement functions with same name in a single class but they must have different type of or different number of arguments. But in case of inheritance it might be possible that in both the classes functions will share same name and with same number of arguments. Like in this example you can see void read and zero arguments void read and zero arguments are available in both the classes that is class A and B. And void show function is also available in both the classes having same name and same number of arguments. So if I inherit a members of class A into class B, then class B will be containing functions with same name and same number of arguments. But this is done coincidentally. I have not implemented this knowingly because it might be possible that one programmer is implementing class A and another programmer is implementing class B. And they both are implementing functions with same name and same number of arguments. And if you apply inheritance between those two classes, then the case might be possible that derived classes having functions with same name and same number of arguments. So to protect this situation C++ provides a powerful feature that is function overriding. It says that derived class can have functions with functions with same name and same number of arguments but these functions will be available in base and derived classes separately. So here you can see I have implemented this concept now in main function I am going to create object of B class. Now I am calling read function and I am calling print sorry show function. So object of B class is created which is calling read and show function and as I have explained earlier derived class that is B class is having two definitions of read and two definitions of show one from base class and one from derived class. But first priority will be given to the functions of derived class because object of derived class is created. So this way function overriding is implemented which says that derived class can contain functions with same name and same number of arguments but one should be available in base class and another should be available in derived class. So now I am executing this code. So here read function of derived class and show function of derived class will be executed as you can see here it is asking for a value I have entered five and it is displaying y equals to five and why is the attribute of derived class. So this way function overriding is applicable in C plus plus. You can implement functions with same name and same parameter in two different classes and you can apply inheritance between them. So function overriding is applicable only in the case of inheritance. If you are not implementing inheritance and you are implementing separate classes then the concept of function overriding is not applicable. 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. Thank you for watching this video.