You cant "make" a function a friend to a class without the class "giving away" its friendship to that function. means? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

You cant "make" a function a friend to a class without the class "giving away" its friendship to that function. means?

20th Feb 2017, 2:32 AM
Jayesh Sarvaiya
Jayesh Sarvaiya - avatar
2 Answers
+ 3
It means it (being a 'friend' and having access to the private members of the class) must be explicitly granted by the class. This is done by the class duplicating the function declaration inside the class, and adding the friend attribute to this declaration. Basically, the class controls who its friends are.
20th Feb 2017, 6:57 AM
Ettienne Gilbert
Ettienne Gilbert - avatar
0
according to me it means that the first class will provide its members to friend class under any circumstances
20th Feb 2017, 5:02 AM
Shubham Sharma
Shubham Sharma - avatar