2012-03-26 365 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

相關問題