error c2679错误原因
#include<iostream>
using namespace std;
class Complex
{
private:
double real;
double image;
public:
Complex()
{
real=0;
image=0;
};
void setreal(double a)
{
real=a;
};
void setimag(double b)
{
image=b;
};
double getreal() const;
double getimag() const;
Complex comadd(const Complex &c);
Complex conminus(const Complex &c);
};
double Complex::getreal()const
{
return real;
}
double Complex::getimag()const
{
return image;
}
Complex Complex::comadd(const Complex &c)
{
Complex t;
t.real=c.getreal()+real;
t.image=c.getimag()+image;
return t;
}
Complex Complex::conminus(const Complex &c)
{
Complex p;
p.real=p.getreal()-real;
p.image=c.getimag()-image;
return p;
}
int main()
{
Complex z,x,y,m;
z.setreal(3);
z.setimag(2);
x.setreal(4);
x.setimag(1);
cout<<y.comadd(m)<<endl;
cout<<y.conminus(m)<<endl
return 0;
}
各位大神帮忙看一下红色区域为什么error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class Complex' (or there is no acceptable conversion)