定义一个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
人气:240 ℃ 时间: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
推荐
猜你喜欢
- They _____,_____and______ a lot of nice food,drinks.They_____ themselves
- (a+b+c)的平方可以化简成什么?
- 某市出租车在5km以内,起步价为5元,行程超过5km时,按每km1.2元收费(不足1km按1km计算),某人下车付打车费11元,问出租车走了多远?
- 由坐标平面内的三点A(-2,-1)B(-2,-4)C(5,-4)构成的三角形是()三角形
- 在光的照射下物体影子的什么、方向都和光源的什么方向有关.
- 人步行大约1.2米每秒,请问表示的物理意义是什么?
- 衣带渐宽终不悔,为伊消得人憔悴!表达了什么境界
- 质量为5t的卡车,在行驶时受到的摩擦力是车重的0.05倍,求车受到的摩擦阻力的大小.要公式,七下科学