Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why Friend Function?

friend function
0
Posted

Why Friend Function?

0

If we want to give a non-member function unlimited access to the members of a class we would declare such a function as a friend of that class. (ie friend functions are able to access private and protected data members) Friend property is not Inherited, not transitive and acts only in one direction Note: here you have to pass object as parameter in order to access the class data members.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123