1. 程式人生 > >C語言STL標準模板庫(list)

C語言STL標準模板庫(list)

#include <list>
#include <iostream>
using namespace std;

int main()
{
	list<int> mylist (8,1); 	//8個100  
	mylist.push_back (2); 	//表尾插入    
	list<int> :: iterator it = mylist.begin();  
	//刪除元素   
	mylist.erase(it);  
	//遍歷輸出 
	for (it=mylist.begin(); it!=mylist.end(); ++it)  
		cout << " " << *it;  
	cout << endl; 
	return 0;
}