But to be able to reach any private data within a user defined class you have to declare the global function as a friend within the definition of the class.
为了访问一个用户定义的类里的私有数据,你必须声明全局函数为友元函数,并且在类中定义。
It is also useful for fine-tuning the exportable interface: when you know that the client, by definition, is unable to access some private data, you need not export the entire class.
这对于微调可导出的接口也很有用:如果根据定义,客户无法访问一些私有数据,你没必要导出整个类。
应用推荐