What is the difference between using friend function and scope resolution operator outside a class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between using friend function and scope resolution operator outside a class?

what are are their basic difference and pros and cons?

21st Aug 2017, 1:51 PM
Akankshya Bhattacharyaa
Akankshya Bhattacharyaa - avatar
1 Answer
+ 4
You cannot use a private method of a class using the scope resolution operator outside the class. Using friend function gives full access to data to the friend function and thus, it is very helpful.
23rd Aug 2017, 2:33 AM
Harsh Kumar
Harsh Kumar - avatar