关于C++迭代器的问题,急求解
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
template<class InputIterator,class T>
InputIterator findl(InputIterator first,InputIterator last,const T& value)
{
while(first!=last&&*first!=value)
{
++first;
cout<<"?"<<endl;
}
return first;
}
int darray[10]={1,2,3,4,5,6,7,8,9,0};
vector<int>vdouble(10);
int main()
{
vector<int>::iterator First=vdouble.begin();
vector<int>::iterator Last=vdouble.end();
int d=darray[2];
cout<<*findl( First,Last,d)<<endl;
return 0;
}
输入结果为什么会有十个问号,我感觉应该是三个啊,另外*findl( First,Last,d)的值为什么不是3呢?我是一个新手,求各位大侠解释一下,谢谢。
[解决办法]
vector<int>vdouble(10);
vector<int>vdouble(darray, darray + 10);