读书人

C++标准库中的find()函数如何调用

发布时间: 2013-01-08 14:02:13 作者: rapoo

C++标准库中的find()函数怎么调用?
我写了一段代码:


//value we'll look for
int search_value = 42;
std::vector<int> vec;
vec.push_back(42);
vec.push_back(40);
vec.push_back(41);
//call find to see if that value is present
std::vector<int>::const_iterator result = find(vec.begin(),vec.end(),search_value);

在编译的时候报出错误:
Error1error C3861: 'find': identifier not found
请问怎么解决呢?
[解决办法]
#include<algorithm>

std::find

读书人网 >C++

热点推荐