#The friend function of a class is defined outside the scope of the class, but it has access to the class All private and protected members of . Although the prototype of a friend function appears in the class definition, a friend is not a member function.
Friends can be functions, function templates or member functions, or they can be classes or class templates. In this case, the entire class and all its members are friends.
#The closest equivalent is to create a nested class that will access the private members of the outer class.
Here, the inner class Can access private members of external classes-
class Outer { class Inner { } }
The above is the detailed content of What is the C# equivalent of the friend keyword in C++?. For more information, please follow other related articles on the PHP Chinese website!