概念
A friend function is a function that is not a member of a class but has access to the class’s private and protected members. Friend functions are not considered class members; they are normal external functions that are given special access privileges. Friends are not in the class’s scope, and they are not called using the member-selection operators (. and –>) unless they are members of another class. A friend function is declared by the class that is granting access. The friend declaration can be placed anywhere in the class declaration. It is not affected by the access control keywords.
来自 http://blog.csdn.net/yiruirui0507/article/details/5983333
注意最后一句:友元函数不受访问控制关键字(public等)影响
类内定义友元函数
参数中必须含有该类的参数,否则会找不到函数: