In C ++, adding a friend to a class changes its memory layout?

Also, does it matter where in the class you declare a friend? Does it matter if you add a friend class or friend function?

+7
c ++ private-members encapsulation friend
source share
2 answers

No no. This is pure compilation: similar to access modifiers.

Even though you are writing a declaration inside a class, you really are not adding a friend to the class. You basically declare something else as a friend of the class and simply allow it to access the private members of the class, as if they were public.

+18
source share

As already mentioned, this is a pure compile-time mechanism.

+1
source share

All Articles