 Hello friends, I am Sanjay Gupta. In this video I am going to demonstrate you how you can implement the concept of friend function for implementing maximum and minimum functions in C++. Before starting, you can note my information. You can connect with me by following these details. You can download my app Techimace that is available on Google Play. You can search my channel on YouTube by my name Sanjay Gupta. You can open my channel. You can subscribe it by clicking on this button. Here various programming languages related videos and playlists are available. You can watch and you can improve your programming skills by these videos. Now coming on to the topic. I am implementing two friend functions in this demonstration. So I have already implemented a code for you. Here header file is included. Then STD which is predefined namespace. I have used it using using keyword. Then advanced declaration of class 2 is available here because I have used this class before its definition. That's why I have declared it here. So whenever you want to use name of class before its definition, then you have to declare it first. Then I have defined class 1. Inside it I have declared a variable int a. Then in public section read function is defined. This read function will be printing enter a number message on console. And L is for new line. Then the entered number will be stored inside a using scene. Then I have declared two functions as friend function. First one is max. Second one is min. Both having written type void. Both are friend functions. Both are having two arguments, one of class one and second of class two. So these are just declarations. After termination of class one, I have defined class two in same way as class one is defined. Here one attribute B is declared. Then read function is implemented which will read a number using C out and C in. The entered number will be stored inside B. Then two functions are declared here which are friend function max and min. These functions are similar to class one. And both the functions will be having two arguments of class one and two respectively. Then two definitions are implemented. One for max and one for min. Max is having two arguments inside X and Y of class one and two. Then if condition is comparing their attributes A and B and accordingly the result will be displayed. Notice that these A and B attributes are declared in private section of private sections of class one and two. And still we are accessing them together in this function because this max function is friend function of both the classes. Similarly, main function is implemented. Here if condition is modified here less than sign is available instead of greater than rest of the statements are same and message is changed here lesser is printed instead of greater. So these two functions are friend functions in this program. Then in main function one class object A1 is declared two class object B1 is declared then A1 is calling read of class one B1 is calling read of class two. So two numbers will be entered. Then max function is called A1 and B1 both are passed as an argument. Then main function is called A1 and B1 both are passed as arguments. So this way calling of friend function is achieved in main function. So I hope you have understood the demonstration. Now I am going to execute this code for you. It is asking for two numbers. So first number I have entered two. It is asking for second number. I am entering six. You can see class two value is greater. So class two value is six. It is greater and class one value is lesser that is two. So through a single code we are identifying or we are able to identify which one is maximum and which one is minimum. So friends if you want to implement more than one friend functions in two or more than two classes then it is possible in C++. I hope you have understood the concept well. If you want to watch more programming related videos you can open my channel Sanjay Gupta on YouTube. You can subscribe it. Here various programming languages related videos are available. So improve your programming skills by watching my videos. Thank you for watching this video.