求教:友元函数无法访问类的私有成员
#include <iostream>using namespace std;
class CVector
{
private:
int x;
int y;
int z;
public:
friend ostream& operator <<(ostream& out,CVector V);
};
ostream& operator <<(ostream& out,CVector V)
{
out<<V.x<<endl;//编译时提示这里不能访问CVector的私有成员x。求教
return out;
}
int main()
{
return 0;
}