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
*/ 
posted @ 2018-04-27 07:17  老耗子  阅读(79)  评论(0编辑  收藏  举报