重载流插入运算符 出错!
程序代码:
/* CppHead.h 文件*/ #include <iostream.h> class ibm { public: ibm(int = 0,int = 0); friend ostream & operator+(ostream &a, ibm &); private: int x; int y; }; ibm ::ibm(int a, int b) { x = a; y = b; } ostream & operator +( ostream &output, ibm &b) //重载 { output << b.x << " " << b.y << endl; return output; } /////////////////////////////////////////////////////// #include "CppHead.h" int main(void) { ibm t(100, 200); cout << t; return 0; }编译的时候提示:E:\练习文件\【C++】\CPP\CPP.CPP(9) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class ibm' (or there is no acceptable conversion)
执行 cl.exe 时出错.
问题怎么解决呀??