#include<iostream>
#include<string>
using namespace std;
class Person
{
public:
int m_age;
string m_name;
Person(int age,string name)
{
m_age = age;
m_name = name;
}
//重载运算符==
bool operator==(Person &p)
{
if (m_age == p.m_age && m_name == p.m_name)
{
return true;
}
else
{
return false;
}
}
};
int main()
{
Person p1(18,"Bruce");
Person p2(18, "Bruce");
if (p1 == p2)
{
cout << "p1和p2相等" << endl;
}
else
{
cout << "p1和p2不相等" << endl;
}
system("pause");
return 0;
}