#include
#include
using namespace std;//
class point
{
double x,y;
public:
point (double x0=0, double y0=0)//函数“point::point(double,double)”已有主体,所以删了下面一段
{
x=x0;
y=y0;
}
point operator + (point pt2);
double operator ^ (point pt2);
void display();
};
point point::operator +(point pt2)
{
point p;
p.x=x+pt2.x;
p.y=y+pt2.y;
return p;
}
double point::operator ^(point pt2)//改为double
{
point p;
p.x=(x-pt2.x)*(x-pt2.x);
p.y=(y-pt2.y)*(y-pt2.y);
return sqrt(p.x+p.y);//改为p.x和p.y
}
void point::display()
{
cout<<"("<
int main() //
{
//point s0, s1(1.2, -3.5), s2(-1.5, 6),s4;
point s0, s1(2, 3), s2(2, 5),s4;//为说明是个距离,用简单的数据
cout<<"s0=";
s0.display();
cout<<"s1=";
s1.display();
cout<<"s2=";
s2.display();
s0 = s1 + s2; //“s1+s2”处,将调用“operator +”函数
cout<<"s0=s1+s2=";
s0.display();
s4=s1^s2; //“s1^s2”处,将调用“operator ^”函数
cout<<"s1^s2=";//多了一个<符号,且这个值是一个距离,不需要用坐标表示,LZ改改吧,如果还需要什么可以联系我
s4.display();
system( "pause" );//系统暂停
return 0;//
}
世界上最烂的程序...