As we know that Private data of a Class can’t be Accessed with the help of an Object. Means if a Class Contains Some Data Members those are Private in nature then we cant Accessed those data Members with the help of an Object, from Outside the Class. So that if we want to do this. Then we must have to use the Friend Function. If a Function declared by using the Friend Keyword, then they can use the Private Data of a Class with the help of an Object.
But there are Some Restrictions those must be used when we are using the Friend functions.
1) A Friend Function Never has a Function definition.
2) Friend Functions are Always Defined from Outside the Class Without using name of Class and Without the Scope Resolution Operator.
3) Friend Functions always uses the Object of a Class because friend functions always uses the object of a class to Access the Private Data of a Class.