
c++ Vector 使用find 50
Classuser{intid;intname;intlevel;booloperator==(constuser&objstruct)const{returnobjst...
Class user
{
int id;
int name;
int level;
bool operator==(const user& objstruct) const
{
return objstruct.id== id;
}
}
user nd;
nd.id= id;
it = find(UserInfo.begin(), UserInfo.end(), nd);
这样只能查找id如何通过 name查找或者通过level查找 展开
{
int id;
int name;
int level;
bool operator==(const user& objstruct) const
{
return objstruct.id== id;
}
}
user nd;
nd.id= id;
it = find(UserInfo.begin(), UserInfo.end(), nd);
这样只能查找id如何通过 name查找或者通过level查找 展开
1个回答
展开全部
bool operator==(const user& objstruct) const
{
return objstruct.id== id;
}
通过 name查找,就把重载函数改成这样:
bool operator==(const user& objstruct) const
{
return objstruct.name== name;
}
通过 level查找,就把重载函数改成这样:
bool operator==(const user& objstruct) const
{
return objstruct.level== level;
}
{
return objstruct.id== id;
}
通过 name查找,就把重载函数改成这样:
bool operator==(const user& objstruct) const
{
return objstruct.name== name;
}
通过 level查找,就把重载函数改成这样:
bool operator==(const user& objstruct) const
{
return objstruct.level== level;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询