//Function to find the distance between 2 points
TLength CPoint::Distance(const CPoint& point) const
{
TLength horiz = abs(point.X() - OBJECT.X());
TLength vert = abs(point.Y() - OBJECT.Y());
TLength dist = sqrt(pow(horiz,2) + pow(vert,2));
return dist;
};
int main()
{
const CPoint a = CPoint(4,5);
const CPoint b = CPoint(1,1);
a.Distance(b);
};
Run Code Online (Sandbox Code Playgroud)
是否有一个术语可以代替 OBJECT 来使用函数 Distance 中的 a 值?