What is Friend Function ?
(1) C++ allows the common function to be made friendly with more than one classes, there by allowing the function to have access to the private data of classes. Such a function need not be member of any of classes.
(2) Non-member function cannot have access to the private data of a class. However, there could be a situation where user would like two classes to share a particular function. At this situation friend
function is used.
(3) The keyword “friend” declares the function to be friendly with that class. This function is defined as a normal C++ function. The function definition does not use class-name, keyword friend or scope resolution operator.