class Person {
public:
Person(string name, int age)
{
this->m_Name = name;
this->m_Age = age;
}
//------------------------------------------
//重载== 让底层find知道如何对比 person 自定义数据类型
bool operator==(const Person& p)
{
if (this->m_Name == p.m_Name && this->m_Age == p.m_Age)
{
return true;
}
else{
return false;
}
}
}
//------------------------------------------
vector<Person>::iterator it = find(v.begin(), v.end(), p2);
if (it == v.end())
{
cout << "没有找到!" << endl;
}
find 函数 查找 自定义数据类型
最新推荐文章于 2023-05-17 17:46:40 发布
博客围绕find函数查找自定义数据类型展开,虽未给出具体内容,但可知核心是利用find函数对自定义数据类型进行查找操作,属于信息技术领域编程相关内容。
5721

被折叠的 条评论
为什么被折叠?



