#include<iostream>
#include<math.h>
using namespace std;
class point
{
private:
int x;
int y;
public:
point(int a,int b)
{
x=a;
y=b;
}
friend double distance (point p1,point p2);
};
double distance(point p1,point p2)
{
double d;
d=pow(p1.x-p2.x,2)+pow(p1.y-p2.y,2);
return sqrt(d);
}
int main()
{
point p1(3,4),p2(0,0);
cout<<"两点之间的距离为:"<<distance(p1,p2)<<endl;
return 0;
}
错误
f:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_iterator_base_types.h||In instantiation of 'struct std::iterator_traits<point>':|
f:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_iterator_base_funcs.h|114| required by substitution of 'template<class _InputIterator> typename std::iterator_traits::difference_type std::distance(_InputIterator, _InputIterator) [with _InputIterator = point]'|
F:\c语言练习\zuoye\main.cpp|26|required from here|
f:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_iterator_base_types.h|166|error: no type named 'iterator_category' in 'class point'|
f:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_iterator_base_types.h|167|error: no type named 'value_type' in 'class point'|
f:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_iterator_base_types.h|168|error: no type named 'difference_type' in 'class point'|
f:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_iterator_base_types.h|169|error: no type named 'pointer' in 'class point'|
f:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\stl_iterator_base_types.h|170|error: no type named 'reference' in 'class point'|
||=== 生成完成: 6 错误, 2 警告 (0 分, 2 秒) ===|
注æçåºéä¿¡æ¯
In instantiation of 'struct std::iterator_traits<point>':|
说æå¨æå°ç头æ件stl_iterator_base_types.hå½ä¸è¿æä¸ä¸ªä¹å«pointçç±»
æä½ çç±»æ¹ä¸ªååå§
æ¯å¦æ¹æPoint
é£ä¹å°±æ¯
#include<iostream>è¯è¯å§ å
¶ä»ç没ä»ä¹é®é¢ å½æ°åå没å
³ç³» åæ°ä¸åå°±å¯ä»¥