2012-03-26 100 views
10

我刚遇到一个奇怪的错误,说find不是std的成员。错误C2039:'find':不是'std'的成员

错误C2039: '找到':是不是 '性病'

错误C3861中的一员: '查找':没有找到

基本上标识,我想找到一个字符串是否可以在向量中找到

任何想法为什么会发生这种情况?代码帮助告诉我std中有find方法。

所以这基本上是我所做的:

#include "OperatorUtil.h" 
#include <iostream> 
#include <string> 
#include <stdlib.h> 
#include <math.h> 
#include <sstream> 


using namespace saeConfig; 


namespace operatorUtil 
{ 
    bool isIn(const Filter filter, const SearchKey key) 
    { 

    bool result = false; 


    string dimensionStr = key.dimensions.getValue(filter.getFilterKey()); 
    if(filter.getFilterValues().size()>0) 
    { 
     vector<string> vstr= filter.getFilterValues(); 
     std::vector<string>::iterator it;  // Iterator 
     it = std::find(vstr.begin(), vstr.end(), dimensionStr); //ERROR LINE 
     // Check do we have the object in the queue 
     if(it == vstr.end())  
     {   
      result =true; 
     } 
    } 

    return result; 
    } 
} 
+0

您是否尝试过使用Google搜索?此外,此代码示例不可编译,因为我没有其他代码。为了将来尝试发布http://sscce.org代码示例 - 给出正确答案要容易得多。它的工作原理是 – 2012-03-26 07:19:14

回答

29

std::find<algorithm>头文件中定义。添加到开头:

#include <algorithm> 
+0

。可以告诉我为什么发生这种情况? – Rudy 2012-03-26 07:14:25

+10

@Rudy因为C++标准说std :: find在标题中。 – juanchopanza 2012-03-26 07:16:16

相关问题