C++程序不知道为什么运行不过去,我又找不出问题所在
#include <iostream.h>
class complex
{
private:
double x,y;
public:
complex(double xx=0, double yy=0)
{
x=xx;
y=yy;
}
double getx()
{
return x;
}
double gety()
{
return y;
}
void display()
{
cout<<"("<<x;
if(y>0)cout<<"x"<<y<<"*i)";
else if(y<0)cout<<y<<"*i)";
else cout<<")";
}
complex operator + (complex &c1);
};
complex complex::operator + (complex &c1)
{
complex c;
c.x=this ->x+c1.x;
c.y=this ->y+c1.y;
return c;
}
void mian()
{
complex c1(3,4),c2(4,-5),c3;
c3=c1+c2;
c1.display();
cout<<"+";
c2.display();
cout<<"=";
c3.display();
cout<<endl;
}
上面是程序,按F4都不提示,我看不懂了。提示错误好像是错误连接了符号还是什么。我的格式错了?
参考答案:老大,看看main函数你写的是什么????你竟然写成mian(面),它当然不干了。