设计一个点类Point其属性为其x,y坐标,能计算该点到(0,0)的距离.
问题描述:
设计一个点类Point其属性为其x,y坐标,能计算该点到(0,0)的距离.
答
#include class Point{public:Point(const double &ax =0.0,const double &aY=0.0):x(ax),y(ay){}Point(){}doubel Distance(){return sqrt(x*x+y*y)}private:double x;double Y;}