头文件: #include <iostream> using namespace std; class qqq {public: qqq():real(0),imag(0){} qqq(int x,int y):real(x),imag(y){} qqq operator+(qqq&c2); friend ostream&operator<<(ostream&,qqq&); private: double real; double imag; }; 实现: #include "stdafx.h" #include <iostream> #include "qqq.h" using namespace std;
qqq qqq::operator +(qqq &c2) {return qqq(real+c2.real,imag+c2.imag); }
ostream&operator<<(ostream&output,qqq&c) {output<<c.real<<c.imag<<endl; return output; } 编译的时候说是 重载〈〈不能用类qqq的私有成员 可是我已经把它声明成friend的啦?