朋友職能應該能夠訪問班級私人會員嗎? 那麼,我在這裏做錯了什麼?我已經將我的.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