定义一个Point类并用成员函数 double Distance(const& Point)求两点间距离
#include
#include
using 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=sqrt((Point.X-X)*(Point.X-X)+(Point.Y-Y)*(Point.Y-Y));
}
void show()
{
cout
人气:107 ℃ 时间:2020-06-18 19:07:50
解答
#include
#include
using 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 &p) //传入对象引用
{
return sqrt((X-p.X)*(X-p.X)+(Y-p.Y)*(Y-p.Y));
}
void show(const Point &p)
{
cout
推荐
猜你喜欢
- 辽东低山丘陵和半岛丘陵区是我国最大的苹果产区为什么错,哪里错?
- 把干燥的纯净的20g KClO3与7g MnO2的混合物放入试管中加热一段时间后,将试管冷却后,称量到22.2g固体
- Is living time must be joyful,because you must die are very long翻译句子
- 0·∞型极限等于A?
- 一辆汽车从甲地到乙地,4小时行了全程的15分之4,照这样计算,5小时行全程的几分之几?(要有算式)
- 我们是6班,举办运动会,帮忙想个口号,格式最好4句,每句4个字,
- 上面一个雨下面是一个云的字怎么读
- 15;( )=0.75=21/( )=16分之( )=( )%