使用的是vc6.0发生了错误,应该是要调试,想知道怎么调试
#include<iostream>
using namespace std;
#include<cmath>
class point
{
private:
double m_x,m_y;
public:
point(double x,double y)
{
m_x=x;
m_y=y;
}
void setxy()
{
cout<<"("<<m_x<<","<<m_y<<")"<<endl;
}
friend double distance(point p1,point p2);
};
double distance(point p1,point p2)
{
double x=p1.m_x-p2.m_x;
double y=p1.m_y-p2.m_y;
return sqrt(x*x+y*y);
}
int main()
{
point a(3,4),b(4,5);
double n=distance(a,b);
a.setxy();b.setxy();
cout<<"距离为:"<<n<<endl;
return 0;
}
error C2785: 'int __cdecl std::distance(_II,_II)' and 'double __cdecl distance(class point,class point)' have different return types
c:\文件下载\microsoft visual studio\vc98\include\utility(100) : see declaration of 'distance'
double n=distance(a,b);
----》
double n=::distance(a,b);