#include "test3.h"
struct Test
{
string Name;
int order;
bool operator < (Test & b) {
return order > b.order;
}
};
void main()
{
list testList;
Test te;
te.Name = "AAA";
te.order = 1;
testList.push_back(te);
te.Name = "BBB";
te.order = 3;
testList.push_back(te);
te.Name = "CCC";
te.order = 2;
testList.push_back(te);
te.Name = "DDD";
te.order = 5;
testList.push_back(te);
te.Name = "EEE";
te.order = 4;
testList.push_back(te);
testList.sort();
for(list::const_iterator citer = testList.begin(); citer != testList.end(); ++citer)
{
cout << citer->Name << "\t" << citer->order << "\n";
}
cout << endl;
}
list用法http://blog.csdn.net/lskyne/article/details/10418823
阅读(1284) | 评论(0) | 转发(0) |