It can be declared in any number of classes using the keyword friend. | It can be declared only in the private, public, or protected scope of a particular class. |
This function has access to all private and protected members of classes. | This function has access to private and protected members of the same class. |
One can call the friend function in the main function without any need to object. | One has to create an object of the same class to call the member function of the class. |
The Friend keyword is generally used to declare a function as a friend function. | In these, there is no such keyword required. |
It cannot be called using, can be invoked like a normal function without using an object, defined outside the class scope, etc. | It has its own prototype within the class definition, operates on any object of the class, has access to all members of the class, etc. |
This method provides access to private and protected data members. | This method provides modularity to a program. |
It is generally used to modify or change private and protected data members of the class. | It is generally used to improve code reusability and to make code maintainable. |
It also provides additional functionality that is kept outside class, provides functions that need data, allows sharing private class information by non-member function, etc. | It allows access to internal private data, can be used a general protocol or interface, use for internal purpose only, and non-publishable operations such as initialization and intermediate results of computation. |
In this, the binary operation usually takes two explicit parameters. | In this, binary operations usually take only one explicit parameter. |
The unary operator takes at least one explicit parameter. | The unary operator does not take any explicit parameter. |
It is not a part of the class. | It is a part of the class definition and is invoked by a particular object. |