我在使用以下代码时遇到问题,似乎无法弄清楚出了什么问题
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
double distance(int a, int b)
{
return fabs(a-b);
}
int main()
{
vector<int> age;
age.push_back(10);
age.push_back(15);
cout<<distance(age[0],age[1]);
return 0;
}
错误在于函数距离的调用。
/usr/include/c++/4.6/bits/stl_iterator_base_types.h: In instantiation of ‘std::iterator_traits<int>’:
test.cpp:18:30: instantiated from here
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:166:53: error: ‘int’ is not a class, struct, or union type
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:167:53: error: ‘int’ is not a class, struct, or union type
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:168:53: error: ‘int’ is not a class, struct, or union type
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:169:53: error: ‘int’ is not a class, struct, or union type
/usr/include/c++/4.6/bits/stl_iterator_base_types.h:170:53: error: ‘int’ is not a class, struct, or union type