【发布时间】:2013-07-30 08:22:40
【问题描述】:
有可能吗?
class sample {
private:
int x;
public:
friend void fun();
};
friend 没有参数的函数!
我认为不可能
因为友元函数不是类的“成员” 所以我们不能用类对象调用
喜欢:
sample s;
s.fun();
【问题讨论】:
-
@sehe:为什么?还有墨守成规的朋友。
-
@Nawaz here let me explain
-
@P0W “这有意义吗”是什么意思?
-
@MarkGarcia 我的意思是为什么要创建类对象然后以这种方式访问私有成员。
标签: c++ class friend-function