list-resize

////////////////////////////////////////
//      2018/04/26 19:50:11
//      list-resize

// change the size of the list
#include <iostream>
#include <list>

using namespace std;

int main(){

    list<int> l(10);
    cout << "Size of list l:" << l.size() << endl;

    l.resize(100);
    cout << "After l.resize(100)" << endl;
    cout << "Size of list l:" << l.size() << endl;


    l.resize(5);
    cout << "After l.resize(5)" << endl;
    cout << "Size of list = " << l.size() << endl;
    return 0;
}

/*
OUTPUT:
    Size of list l:10
    After l.resize(100)
    Size of list l:100
    After l.resize(5)
    Size of list = 5
*/ 
原文地址:https://www.cnblogs.com/laohaozi/p/12537939.html