c++之list学习

#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <list>

using namespace std;


int main(int argc, char * argv[])
{
    list<int> lst;

    lst.push_back(10);  //从链表尾部添加
    lst.push_front(20);  //从链表头部添加

    lst.insert(lst.begin(), 10, 1);  //从链表头开始lst.begin(),连续插入10个元素1;

    list<int>::iterator itor;  //迭代器
    for (itor = lst.begin(); itor != lst.end(); itor++) //遍历vector
    {
        lst.erase(itor);      //删除节点;
    }

    lst.pop_back();      //从尾部删除节点;
    lst.pop_front();      //从头部删除节点;

    system("pause");
    return 0;
}
原文地址:https://www.cnblogs.com/weiyouqing/p/9677897.html