注册 登录
编程论坛 C++教室

为何friend函数不能访问Protected数据成员

ywdeng22 发布于 2007-04-04 22:33, 1823 次点击

我使用的IDE是VC++6.0(sp6)
在类中用友元函数重载“<<”流操作符,数据成员声明为protected,编译时出错:
error C2248: 'x' : cannot access protected member declared in class 'Point'

若把数据成员声明为public,则没问题。
friend 不是可以访问protected数据成员吗,实在不解。

1 回复
#2
sphinx20022007-04-05 12:53
友元函数应该是能访问protected成员的
1