#include <vector>
#include <algorithm>
#include <iostream>
class example
{
public:
example(int val)
{
i = val;
}
bool operator==(example const & rhs)
{
return (i == rhs.i) ? true : false;
}
private:
int i;
};
using namespace std;
int main(void)
{
vector<example> ve;
ve.push_back(1);
vector<example>::iterator it;
example elem(1);
it = find(ve.begin(), ve.end(), elem);
cout<<boolalpha<<(*it == elem);
}
STL标准函数find进行vector list链表查找
最新推荐文章于 2023-12-21 10:00:11 发布