在这个函数里,传入的是迭代器引用会报错,但非引用就不会报错,为什么呢?
报错类型给的是没有与这些操作数匹配的"<<"
#include <iostream>
#include <vector>
using namespace std;
bool find(vector<int>::iterator& begin, vector<int>::iterator& end, int i) {
while (begin != end) {
if (*begin == i) {
return true;
}
++begin;
}
return false;
}
int main() {
vector<int> a{ 5, 2, 234, 62, 1, 43, 2, 523, 53 };
cout << find(a.begin(), a.end(), 165) << endl;
}