You can define the friend function in a friend declaration, and it has interesting behavior that cannot be obtained in any other way (if the inclusion type is a template).
You cannot define a friend class in a friend declaration, and that is not necessary. If you want to create a new inline type with full access, you can simply create a nested type. As a member, he will have full access to the closing type. The only difference is that the type will not be found at the namespace level, but you can add a typedef if necessary (or, alternatively, define a class at the namespace level and just declare friendships inside the class).
class Outer { int x; class Inner { static void f( Outer& o ) { ox = 5; }
source share