模板函数find这样做为什么有错,该怎么解决!!!!!!!!!!!!
struct PERSONINFO
{
int OnLine;
char UserId[10];
bool operator==(const PERSONINFO & rhs)const
{
return ( OnLine == rhs.OnLine && UserId == rhs.UserId);
}
};
PERSONINFO pInfo ;
pInfo.OnLine = 3;
strcpy( pInfo.UserId , "a" );
m_list.push_back(pInfo);
pInfo.OnLine = 4;
strcpy( pInfo.UserId , "b" );
m_list.push_back(pInfo);
pInfo.OnLine = 1;
strcpy( pInfo.UserId , "c" );
m_list.push_back(pInfo);
PERSONINFO Info ;
Info.OnLine = 3;
strcpy( Info.UserId , "a" );
list<PERSONINFO>::iterator it_;
it_ = find(m_list.begin(), m_list.end(), &Info);
报错:d:\microsoft visual studio\vc98\include\algorithm(43) : error C2678: binary '==' : no operator defined which takes a left-hand operand of type 'struct PERSONINFO' (or there is no acceptable conversion)
E:\SortList\SortListDlg.cpp(258) : see reference to function template instantiation 'class std::list<struct PERSONINFO,class std::allocator<struct PERSONINFO> >::iterator __cdecl std::find(class std::list<struct PERSONINFO,class std::allocat
or<struct PERSONINFO> >::iterator,class std::list<struct PERSONINFO,class std::allocator<struct PERSONINFO> >::iterator,struct PERSONINFO *const & )' being compiled