What is the use of friend function?

Sometime a function is best shared among a number of different class. Such functions can be declared either as member functions of one class or as global fuctions. In either case they can be set to be friends of other classes, by using a friend specifier in the class that is admitting them. Such functions can use all attributes of the class which names them as a friend, as if they were themselves members of the function but instead of requiring an implementation with the name of that class attached by the double colon syntax, a global function or member fuction of another class provides the match.