Chinaunix首页 | 论坛 | 博客
  • 博客访问: 107452
  • 博文数量: 25
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 165
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-17 00:54
文章分类

全部博文(25)

文章存档

2015年(25)

我的朋友

分类: C/C++

2015-03-22 01:14:22

#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
阅读(1222) | 评论(0) | 转发(0) |
0

上一篇:单向链表及操作

下一篇:close_wait

给主人留下些什么吧!~~