我无法运行此代码来打印两点之间的距离.我只是个初学者
I cannot run this code to print distance between two points. I am just a beginner
我写了下面给出的代码来打印两点之间的距离,但它会引发很多错误。据我所知,错误在于";空隙公式(距离o1,距离o2(";和main。但我找不到确切的错误,因为我只是一个初学者。请引导我。
class distance
{
int a, b;
public:
int c, d;
friend void formula(distance, distance);
distance(int a1, int b1)
{
a = a1;
b = b1;
}
};
void formula(distance o1, distance o2)
{
c = o2.a - o1.a;
d = o2.b - o1.b;
cout<<"The distance is "<<sqrt((c*c)+(d*d))<<endl;
}
int main()
{
distance c1(1, 2), c2(3, 4);
formula(c1, c2);
return 0;
}
函数中没有定义公式c和d。如果你写,这个函数就会知道它们
o1.c = ...
o1.d = ...
相关文章:
- C++中std::resize(n)和std::shrink_to_fit之间的区别
- int(c) 和 c-'0' 之间的区别。C++
- 在cuda线程之间共享大量常量数据
- 在c代码之间共享数据的最佳方式
- Mix_Init和Mix_OpenAudio SDL之间的区别是什么
- C++ 使用 assign 函数的字符串与直接使用 '=' 更改值的字符串之间的区别
- VSOMEIP-2个设备之间的通信(TCP/UDP)不工作
- 用C++程序计算圆锥体的体积、球体的体积、八边形的面积和两点之间的距离
- 找到两点之间的中点
- 在C++中计算两点之间的角度,得到了奇怪的结果
- 使用Opencv/c++在Stream中的两点之间绘制aline
- 如何知道数组中两点之间的单元格数
- 如何有效地计算两点之间的角度
- 如何使用两点和步骤 c++ 之间的元素初始化向量
- 查找二维数组中两点之间的距离
- 尝试在c++中找到(x,y)坐标系中两点之间的最短路径.误差11db
- C++检测两点之间的碰撞,并在发生碰撞时从法线上反弹
- 复杂性理论-c++中两点之间的最小距离
- 我怎么做两点之间的碰撞检查呢?(c++)
- 查找两点之间的距离