飛天

快乐的生活......

 

标准模板库(STL)学习指南之List容器

 

 1#include <list>
 2#include <string>
 3#include <iostream.h>
 4#include <algorithm> //for_each()
 5   
 6using namespace std;
 7
 8
 9 void PrintIt(string &strPrint)
10 {
11 cout<<strPrint<<endl;
12 }

13
14int _tmain(int argc, _TCHAR* argv[])
15{
16 list<string> aa;
17 char a;
18
19 aa.push_back("aaaaaaa");
20 aa.push_back("ccccccc");
21 cout<<aa.size()<<endl;
22
23 list<string>::iterator aaiterator;
24
25 for(aaiterator=aa.begin();aaiterator!=aa.end();aaiterator++)
26 {
27  cout<<*aaiterator<<endl;
28 }

29 cin>>a;
30
31
32 cout<<"方法二:"<<endl;
33 for_each(aa.begin(),aa.end(),PrintIt);
34
35 return 0;
36}

37
38
39
40

posted on 2007-08-02 17:43 飛天 阅读(313) 评论(0)  编辑 收藏 引用 所属分类: C/C++


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

文章分类

文章档案

Blogs

搜索

最新评论

阅读排行榜

评论排行榜