c++程序,编译器vc++6.0 求大神看看哪错了, 运行结果不对
程序代码:
#include <iostream.h> class com { public: //运算符重载 friend istream & operator >> (istream &,com &); friend ostream & operator << (ostream &,com &); friend com & operator + (com &,com &); private: int real,image; }; ostream & operator << (ostream & output,com &c) { output<<"("<<c.real<<"+"<<c.image<<"i)"; return output; } istream & operator >> (istream & input,com & c) { input>>c.real>>c.image; return input; } com& operator + (com &a,com &b) { com c; c.real=a.real+b.real; c.image=a.image+b.image; return c; } int main() { com a,b; cout<<"input a="; cin>>a; cout<<"input b="; cin>>b; cout<<"a="<<a<<endl; cout<<"b="<<b<<endl; cout<<"a+b="<<a+b<<endl; return 0; }