list-clear

////////////////////////////////////////
//      2018/04/25 21:19:18
//      list-clear

// removes all elements
#include <iostream>
#include <list>

using namespace std;

int main(){
    list<int> l(5, 10);
    cout << "size of list = " << l.size() << endl;
    l.clear();
    cout << "After l.clear() size of list = " << l.size() << endl;
    return 0;
}


/*
OUTPUT:
    size of list = 5
    After l.clear() size of list = 0
*/
原文地址:https://www.cnblogs.com/laohaozi/p/12537970.html