What is the draw back in using friend function in c++

Showing Answers 1 - 6 of 6 Answers

palanikumar

  • Nov 18th, 2005
 

I think it would be nice to defer compilinginline functions until they are actually used in normal code. Thiswould make writing header files that have inline functions MUCH easierto manage.

  Was this answer useful?  Yes

kbjarnason

  • Jul 2nd, 2010
 

The basic problem is that it blows away your encapsulation.  Friend functions see right through "protected" and "private" and can see blinkin' everything.

Or, in other words, "your friends get to play with your private parts."  :)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions