Showing posts with label What is friend function. Show all posts
Showing posts with label What is friend function. Show all posts

What is friend function? Explain the use with an example.

Friend Function:

Friend functions are those functions which can access all the functions and  variables of a class though it is not a member function of that class. Actually to share a function among two or more classes friend functions are used. If it is declared so, then it will able to access all variables and functions of those classes.