Also, does it matter where in the class you declare the friend ? Does it matter if you add a friend class or a friend function ?
Asked
Active
Viewed 766 times
7
-
1Note that technically, the C++ standard does not define a memory layout for non POD types. – Billy ONeal Jun 23 '10 at 21:09
2 Answers
18
No it doesn't. It's a purely compile-time thing: similar to access modifiers themselves.
Despite the fact that you write the declaration inside the class, you don't really add a friend to a class. You'd basically declare something else as a friend of the class and simply allow it to access the class's private members, as if they were public.

Mehrdad Afshari
- 414,610
- 91
- 852
- 789