0
What is friend function?
Clarify all the workings of 'friend function'
4 Antworten
+ 1
When a function is declared as a friend, it has access to all members of a class (including private members).
+ 1
Think of it like this, a friend function has access to the member variables of another class but does not belong to that class itself. The only restrictions would be private variables (if I remember correctly)
A commenter once explained it as how your friend can use your cup, and your toilet (hopefully not at the same time) in your house but it would be strange if he/she was suddenly searching your bedroom. I stand to be corrected by the wag
0
@Diego
Thanks for the clarity mate
0
Your welcome! I tryed to write an example but i had some problems with internet conection. Sorry for the late answer.Here's an example
https://code.sololearn.com/cjE6b8OV4THU/?ref=app