C++ Friend function

tutorial and example
tutorial and example

A friend function has the right to access all private and protected members of a class although it is defined outside that class’ scope.

Syntax

C++ friend function Example

Output:

C++ friend function in two different class

Output: