In this video session we will discuss one more important feature of C++. That is called friend function. Normally private data members and member function are not accessible outside the class. These members are only accessible inside the class. If we try to access these member outside the class then compiler will generate an error and compilation will not comes to success.
This type of situation is addressed by C++ by using friend function.
Friend function is a special function in C++ which can access private data members of the class. This function is declared inside the class using friend keyword. The syntax of friend function in C++i is as follows.
friend return_type function_name(parameters);
So it is clear that only friend function whose declaration is available inside the class can access private members of class. In our video session we use pointer parameter of the friend function because we want to update the actual value of the object. When this friend function is called then the address of the particular object will be given as parameter.