Difference between friend class and friend member function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Difference between friend class and friend member function?

I want to know how the friend class works?. because Even friend member functions can be used to access both regular and the private variables across classes. Then what is a friend class?? can anyone tell me please?

20th May 2018, 8:25 AM
Sneha Johnson
1 Answer
+ 11
Friend function is a function that is able to access the private and protected members of a class. In contrast, a friend class is a classwhich help in accessing the privatemembers of a class. A friend functionis declared by including its prototype inside the class, antecede it with thekeyword friend. https://techdifferences.com/difference-between-friend-function-and-friend-class.html
20th May 2018, 8:29 AM
Abhivarshini Maddala
Abhivarshini Maddala - avatar