错误C2039:'find':不是'std'的成员

时间:2012-03-26 07:10:39

标签: c++ vector std

我刚刚遇到一个奇怪的错误,它说find不是std。

的成员
  

错误C2039:'find':不是'std'的成员

     

错误C3861:'find':找不到标识符

基本上,我想找出是否可以在向量

中找到字符串

知道为什么会这样吗?代码帮助告诉我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;
   }
}

1 个答案:

答案 0 :(得分:31)

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

#include <algorithm>