error C4716: “operator<<”: 必须返回一个值

来源:互联网 发布:java的applet过时了吗 编辑:程序博客网 时间:2024/06/05 15:57

error C4716: “operator<<”: 必须返回一个值

#include <iostream>using namespace std;class Complex{public:Complex() {real=0;imag=0;}Complex(double r,double i){real=r;imag=i;}Complex operator+(Complex &c2);friend ostream& operator <<(ostream&,Complex&);private:double real;double imag;};Complex Complex::operator+(Complex &c2){return Complex(real+c2.real,imag+c2.imag);}ostream & operator <<(ostream &output,Complex &c){output<<"("<<c.real<<"+"<<c.imag<<"i"<<endl;return output; //loss this one will alarm, please pay attention}int main(){Complex c1(2,4),c2(6,10),c3;c3=c1+c2;cout<<c3;system("pause");return 0;}

0 0
原创粉丝点击