Using friend
is actually very discouraged in C++ (it kinda breaks the whole encapsulation idea), but it comes to my mind an example where only friend is the right approach:
friend ostream & operator<< (ostream & out, const MyClass & C);friend istream & operator>> (istream & in, MyClass & C);