使用函数重载的方法定义两个重名函数,分别求出int型数的两个点间距离和浮点数的两点间距离#include <iostream> #include <cmath> using namespace std; int distance(int x1,int y1,int x2,int y2) { double dis; dis=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); cout<<dis; return 0; } ...
定义一个Point类并用成员函数 double Distance(const& Point)求两点间距离#include#includeusing namespace std;class Point{private:double X,Y;public:Point(double x,double y){X=x;Y=y;}//构造函数double GetX(){return X;}double GetY(){return Y;}double Distance(const& Point){ double d;return d...