求助(关于运算符的重载)
#include <iostream>using namespace std;
class Complex
{public:
Complex( ){real=0;imag=0;}
Complex(double r,double i){real=r;imag=i;}
Complex(int z){zs=z;}
Complex operator+(Complex &c2);
void out( );
private:
int zs;
double real;
double imag;
};
Complex Complex::operator+(Complex &c2)
{Complex c;
c.real=real+c2.real;
c.imag=imag+c2.imag;
c.real=zs+c2.real;
c.imag=c2.imag;
return c;
}
void Complex::out( )
{
cout <<"("<<real<<","<<imag<<"i)"<<endl;
}
int main( )
{
Complex c1(3,1),c2(5,-10),c3(0,12),c4,c5,c6,z=4;
c4=c1+c2;
c5=c1+c3;
c6=z+c3;
cout <<"c4=";c4.out( );
cout <<"c6=";c6.out( );
return 0;
}
帮忙看一下这个程序那里有问题。。