class findx //仿函数 用来查找容器中元素
{
public:
findx(const int Y,int M, int D){Year=Y;Month=M;Day=D;}
bool operator()(STRING& t) //重载()
{
if(t.year == Year && t.month == Month && t.day == Day)
return true;
else
return false;
}
public:
int Year;
int Month;
int Day;
{
public:
findx(const int Y,int M, int D){Year=Y;Month=M;Day=D;}
bool operator()(STRING& t) //重载()
{
if(t.year == Year && t.month == Month && t.day == Day)
return true;
else
return false;
}
public:
int Year;
int Month;
int Day;
};
查找:
vector<STRING>::iterator it = find_if( information.begin( ), information.end( ), findx(y,m,d) );
//迭代器
if(it!=information.end())
{
it->Congradu();
}
else
{
cout<<"NO"<<endl;
}