[求助]关于求两点之间距离
不知错在哪里!s2的调用应该怎样#include<iostream.h>
#include<math.h>
class Cpoint
{ int x1,y1,x2,y2,length1;
float w1,z1,w2,z2,length2;
public:
int length(int ,int ,int ,int );
float length(float,float,float,float);
void print()
{cout<<"length1="<<length1<<'\n';
cout<<"length2="<<length2<<'\n';
}
};
int Cpoint::length(int a,int b,int c,int d)
{
x1=a;
y1=b;
x2=c;
y2=d;
length1=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
return length1;
}
float Cpoint::length(float e,float f,float g,float h)
{w1=e;
z1=f;
w2=g;
z2=h;
length2=sqrt((w1-w2)*(w1-w2)+(z1-z2)*(z1-z2));
return length2;
}
void main()
{ Cpoint s1,s2;
s1.length(1,2,3,4);
s2.length(3.1,5.1,6.1,8.7);
s1.print();
}