In short, one is a class and one is a function. For a function, only one function gains access to private members. For a class, the entire class and all its functions gain access to private members of a friend class.
The friend keyword is used to provide access to private data. Sometimes you may need a helper class or a free class to access private members of another class. For functions, a common example is operator overloading. Perhaps you want to overload the + operator. You can make an operator + function declared outside the class (so that it can be called without an object), and it will need to access the data of the private class.
Check out this site for a detailed description of both how and how to use them.
Joshd source
share