Originally I wanted to access B’s x in A’s func(), but later I found out that I could add a function to B to access A’s. Including can access the included, and the included cannot access the included. This should generally be the case.
I am also a beginner in C++. Is there any other use for declaring A as a member of B? If B is not directly declared as a friend function of A, the members of B can be accessed through A, including private members.
Originally I wanted to access B’s x in A’s func(), but later I found out that I could add a function to B to access A’s.
Including can access the included, and the included cannot access the included. This should generally be the case.
I am also a beginner in C++. Is there any other use for declaring A as a member of B? If B is not directly declared as a friend function of A, the members of B can be accessed through A, including private members.
Please see Section 7.2.1 and Section 7.3.4 of "C++ Primer" for an explanation of Friendship.