C++容器--标准库函数

来源:互联网 发布:数据的独立性是指 编辑:程序博客网 时间:2024/05/21 01:54

     在利用list和Vector容器中的find函数查找值时,总是提示Error 1 error C3861: 'find': identifier not found,

   看MSDN发现,find函数操作并不属于容器的操作方法中,而是使用了c++的标准库函数,所以在使用时,需要使用:

 #include <algorithm> //find函数头文件 

 using namespace std;  

在find函数调用时,加上std:find()。

std::list<int>::iterator Iter; 
Iter = std::find(m_cmdlist.begin(), m_cmdlist.end(), m_iFileCount);
if (Iter == m_cmdlist.end())
{
// cout << "Fruit not found in list" << endl;
m_cmdlist.push_back(m_iFileCount);
}

else

{

//find

}



0 0
原创粉丝点击