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查找
展开
 我来答
进无止境6A
2017-11-15 · TA获得超过133个赞
知道答主
回答量:42
采纳率:83%
帮助的人:20.5万
展开全部
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;
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式