#include <iostream>
#include <string>
#include <list>
#include <vector>
using namespace std;
void PrintList(std::list<int> myints)
{
std::list<int>::iterator it = myints.begin();
for(; it != myints.end() ; ++it)
{
cout << *it << " ";
}
cout << '\n';
}
int main ()
{
std::list<int> myints;
std::cout << "0. size: " << myints.size() << '\n';
PrintList(myints);
for (int i=0; i<10; i++) myints.push_back(i);
std::cout << "1. size: " << myints.size() << '\n';
PrintList(myints);
myints.insert (myints.begin(),10,100);
std::cout << "2. size: " << myints.size() << '\n';
PrintList(myints);
myints.pop_back();
std::cout << "3. size: " << myints.size() << '\n';
PrintList(myints);
return 0;
}
參考網址 http://www.cnblogs.com/oomusou/archive/2008/03/22/1117686.html
http://www.cprogramming.com/tutorial/c/lesson15.html
http://www.cplusplus.com/reference/list/list
留言列表