+ 1
Friend function as private or public
Hi Refer code below : It works fine. But just have a query on friend function. It can be private or public or anywhere ? Does it make any difference based on access specifier It is defined inside ? https://sololearn.com/compiler-playground/ca5VNO2jSp44/?ref=app
2 Respostas
+ 3
"The friend declaration appears in a class body and grants a function or another class access to private and protected members of the class where the friend declaration appears."
"Access specifiers have no effect on the meaning of friend declarations (they can appear in private: or in public: sections, with no difference)."
https://en.cppreference.com/w/cpp/language/friend
+ 3
Thanks Bob_Li