 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can overload plus plus and minus minus operators using friend function in C++. Before starting, you can note my information. You can connect with me by following these details which are available in front of you. You can download my app Techimus that is available on Google Play. Now coming on to the topic. In this video, I am going to demonstrate you how you can overload plus plus and minus minus operators using friend function in C++. I have included a header file IO screen. Then STD namespace is used. Name of class is integer. Inside this class and attribute is declared. Then in public section, first function is defined, which is read. It will display enter a number message on console and the number will be stored inside and variable. Then print function is defined, which will display value on console using this n variable. Then two operators are overloaded. First one is plus plus and second one is minus minus and both the operators are overloaded using the concept of friend. So friend function says that if a function is declared as friend, then it will not receive any argument as implicit argument. So in case of friend function, all implicit arguments are converted into explicit arguments. So plus plus and minus minus both are unary operators. So in case of unary operator, we don't pass any argument explicitly, but these functions are friend functions. So the object, which will call plus plus and minus minus will be passed explicitly and that argument will be received by this i reference variable. Then i dot n is added by one in plus plus and it is subtracted by one in minus minus. So reference variable means if i is modified, then its explicit argument will also be modified automatically. So if we look into the main function, plus plus is called here plus plus i1 and minus minus is called here. So i1 will become explicit argument. Its reference will be shared by i. If we modify value of i, then i1 will be modified automatically. So friends, if we remove the concept of friend, then i1 will be passed implicitly. Otherwise it will be passed explicitly. So first I am executing this code. I am entering five. You can see the output. First value is incremented by one. So output is six. Then it is decremented by one. So output is five. Now if I remove this friend keyword from here and now if I execute this code, it will show an error message because if plus plus and minus minus are not friend function, then we can't pass explicit argument because these are unary operators. So in that case, I have to remove this and I have to write this notation in both the functions. Now if I compile this code, it will properly compile and it will execute properly. You can see the output six and five are displayed. So this demonstration is without using friend function and previous one was using friend function concept. So this is the previous one, which is using the concept of friend function. So I have demonstrated you both the ways that how to overload plus plus and minus minus using friend function and without using friend function. If you are using friend function, then implicit argument will be converted into explicit and if you are not using friend function, then implicit argument will be passed as implicit argument and the output will be printed and output in both the cases are same. Either you are implementing friend function concept or you are not implementing. So I hope you have understood the concept of friend function in case of unary operator overloading. If you want to watch more programming related videos, you can subscribe my YouTube channel that is Sanjay Gupta underscore Tech School. Thank you for watching this video.