朋友职能应该能够访问班级私人会员吗? 那么,我在这里做错了什么?我已经将我的.h文件包含在运营商< <我打算与班级交朋友。有班级但不能访问私人会员的朋友
#include <iostream>
using namespace std;
class fun
{
private:
int a;
int b;
int c;
public:
fun(int a, int b);
void my_swap();
int a_func();
void print();
friend ostream& operator<<(ostream& out, const fun& fun);
};
ostream& operator<<(ostream& out, fun& fun)
{
out << "a= " << fun.a << ", b= " << fun.b << std::endl;
return out;
}
这很有趣,最简单了事情怎么会是最最难找到... – starcorn 2010-07-17 10:26:05
是否'乐趣&'总是有是'const'? – peter 2017-01-02 07:38:32