小编Reb*_*kah的帖子

如何使用调用函数的对象的参数?

//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 值?

c++ function

0
推荐指数
1
解决办法
48
查看次数

标签 统计

c++ ×1

function ×1