#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <functional>
using namespace std;
void test01()
{
vector<int> v1;
for(int i = 0; i < 10; ++i)
{
v1.push_back(i);
}
vector<int>::iterator it = find(v1.begin(), v1.end(), 5);
if(it != v1.end())
{
cout << "find" << *it << endl;
}
else
{
cout << "dont" << endl;
}
}
class Person
{
public:
Person(string name, int age)
{
this->m_Name = name;
this->m_Age = age;
}
bool operator==(const Person &p)
{
if(this->m_Name == p.m_Name && this->m_Age == p.m_Age)
{
return true;
}
else
{
return false;
}
}
string m_Name;
int m_Age;
};
void test02()
{
vector<Person> v1;
Person p1("xiaoming", 10);
Person p2("xiaohong", 20);
Person p3("xiaolan", 30);
Person p4("xiaofang", 40);
v1.push_back(p1);
v1.push_back(p2);
v1.push_back(p3);
v1.push_back(p4);
Person p5("xiaofang", 40);
vector<Person>::iterator it = find(v1.begin(), v1.end(), p5);
if(it == v1.end())
{
cout << "dont" << endl;
}
else
{
cout << "find" << endl;
}
}
int main()
{
//test01();
test02();
return 0;
system("pause");
}