std list 的使用

#include <iostream>
using namespace std;
#include <list>  //stl list是一双向链表,可高效地进行插入删除元素
#include <string>
int main () 
{
  list<string> cc;
  list<string>::iterator pointCC; //iterator迭代器
  cc.push_back("Chocolate");
  cc.push_back("Strawberry");
  cc.push_front("Lime");
  cc.push_front("Vanilla");
  cout << cc.size() << endl;
  for(pointCC=cc.begin();pointCC!=cc.end();++pointCC) 
  {
    cout << *pointCC << endl; //遍历list元素
  }     

  return 0;
}
posted @ 2012-04-29 20:23  潘小雨  Views(4989)  Comments(0Edit  收藏  举报