0 votes
in C Plus Plus by

What is a friend function?

1 Answer

0 votes
by

C++ class does not allow its private and protected members to be accessed outside the class. But this rule can be violated by making use of the “Friend” function.

As the name itself suggests, friend function is an external function that is a friend of the class. For friend function to access the private and protected methods of the class, we should have a prototype of the friend function with the keyword “friend” included inside the class.

Related questions

0 votes
asked Jan 7 in C Plus Plus by GeorgeBell
0 votes
asked Jan 4 in C Plus Plus by GeorgeBell
...