#include<iostream>
#include<set>
using namespace std;
struct row
{
int num;
string str;
};
struct classcmp
{
bool operator()(const row& lhs, const row& rhs)
{
return lhs.num < rhs.num;
}
};
struct classcmp1
{
bool operator()(const int& lhs, const int& rhs)
{
return lhs < rhs ;
}
};
int main(void)
{
set<row, classcmp> s5 ;
row a,b,c;
a.num = 1;
b.num = 2;
c.num = 3;
s5.insert(a);
s5.insert(b);
s5.insert(c);
cout<<"over"<<endl;
set<row>::iterator it;
for(it = s5.begin(); it != s5.end(); it++)
{
cout<<(*it).num<<endl;
}
//system("pause") ;
return 0;
}
参考:
http://www.cnblogs.com/graphics/archive/2010/06/01/1749569.html