What is the difference between Friend Functions and Friend classes? How could they be useful or used? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

What is the difference between Friend Functions and Friend classes? How could they be useful or used?

Real life analogy helpful

23rd Jul 2017, 3:42 PM
Sai Yerni Akhil
Sai Yerni Akhil - avatar
3 ответов
+ 4
you are a good player for challenger. !
27th Jul 2017, 11:23 AM
Victor Manuel Hernandez
Victor Manuel Hernandez - avatar
+ 2
If you declare a function as friend, then that function can access class's private members. On the other hand, if you declare class B as a friend class of the class A then every method of class B is a friend function to class A and can access its private members. Most common uses are quick fixes in long programs or overloading binary operators,etc.
26th Jul 2017, 12:56 PM
Nikola Kesic
Nikola Kesic - avatar
0
Thank you 😁
27th Jul 2017, 11:23 AM
Nikola Kesic
Nikola Kesic - avatar