struct myfunc
{
bool operator()(int v1,int v2)const
****
{
return v1 > v2;
}
};
void test02() {
set<int, myfunc> myset2;
myset2.insert(1);
myset2.insert(100);
myset2.insert(28);
myset2.insert(43);
myset2.insert(5);
myset2.insert(20);
myset2.insert(59);
for_each(myset2.begin(), myset2.end(), myprint);
}
struct myfunc2 {
bool operator()( const Maker& m1, const Maker& m2)const
****
{
return m1.age > m2.age;
}
};
template <class T>
void printmyfunc(T& m) {
for (set<Maker, myfunc2>::iterator it = m.begin(); it != m.end(); it++)
{
cout << it->name << " " << it->age << endl;
}
}
void test05() {
set<Maker,myfunc2> mymaker;
mymaker.insert(Maker("aaaa", 18));
mymaker.insert(Maker("bbbb", 15));
mymaker.insert(Maker("cccc", 17));
printmyfunc(mymaker);
}