Possible Duplicate:
When should you use 'friend' in C++?
There is a detailed explanation here, but I would like to know what is the practical use of Friend function.
How I can decide when I should go with a friend function rather than a member function?
In most cases,
frienddeclarations are a code-smellsince it breaks encapsulation.Developers often use
friendfor a quick-fix to a problem. However a good starting design or some refactoring (more often more than less) exclude the necessity for it.EDIT:
Even in @Darhuuk’s example, a friend declaration is not needed. You can have getters for the specific fields you want to print.