1(C++ primer 5th edition 7.2.1: Declarations for Friends)
A friend declaraton only specifies access. It is not a general declaration of the function.//
If we want users of the class to be able to call a friend function, then we have to make a friend visible to users of the class, the usual method is to declare each friend in the same header as the class itsself, outside the class.
也就是说,在一个class的definition body中说一个函数是这个class的friend,起到的作用只是赋予这个函数能够使用class的nonpublic成员的权限。
而如果我们需要用户使用这个函数的话,我们需要告诉compiler这个函数的原型(给出所有调用这个函数需要的information),就要做出一般的声明,这就是一般的function declaration。
2(C++ primer 5th edition 7.2)
关于friend的另几个概念:
一:"Friend eclarations may appear only(注意only) inside a class definition",进一步的是“they may appear anywhere in the class.”这是关于friend出现位置的要求。
二:"Friends are not members of the class and are not affected by the access control of the section in which they are declared." 也就是说,friend虽然在class的definition中出现,但是它却不是class的一个member,并且也不受private,public这种权限的控制。