关键做好类对象的运算符重载
#include "stdafx.h"
#include <vector>
#include <algorithm>
class people
{
public:
int age;
char name[32];
public:
bool operator == (const people&T)
{
if (age == T.age)
{
return true;
}
return false;
}
};
typedef std::vector<people> myPeople;
typedef myPeople::iterator myPeopleIt;
int _tmain(int argc, _TCHAR* argv[])
{
using namespace std;
people m_p1;
myPeople m_p;
m_p.push_back(m_p1);
myPeopleIt it = find(m_p.begin(),m_p.end(),m_p1);
if (it != m_p.end())
{
printf("find it");
}
return 0;
}