#include <iostream>
#include <set>
using namespace std;
class Person
{
public:
Person(string name, int age)
{
this->m_name = name;
this->m_age = age;
}
string m_name;
int m_age;
};
class MyCompare
{
public:
bool operator()(const Person &p1, const Person &p2)
{
return p1.m_age > p2.m_age;
}
};
void printSet (set<Person, MyCompare> s)
{
for (set<Person, MyCompare>::iterator it = s.begin(); it != s.end(); it ++)
{
cout << it->m_name << it->m_age << endl;
}
}
void test01 ()
{
set<Person, MyCompare> s;
Person p1("tom", 22);
Person p2("jack", 11);
Person p3("lisi", 33);
Person p4("wangwu", 10);
s.insert(p1);
s.insert(p2);
s.insert(p3);
s.insert(p4);
printSet(s);
}
int main ()
{
test01();
return 0;
}