list clear c 2b 2b

Solutions on MaxInterview for list clear c 2b 2b by the best coders in the world

showing results for - "list clear c 2b 2b"
Fabiana
21 Aug 2020
1// clearing lists
2#include <iostream>
3#include <list>
4
5int main ()
6{
7  std::list<int> mylist;
8  std::list<int>::iterator it;
9
10  mylist.push_back (100);
11  mylist.push_back (200);
12  mylist.push_back (300);
13
14  std::cout << "mylist contains:";
15  for (it=mylist.begin(); it!=mylist.end(); ++it)
16    std::cout << ' ' << *it;
17  std::cout << '\n';
18
19  mylist.clear();
20  mylist.push_back (1101);
21  mylist.push_back (2202);
22
23  std::cout << "mylist contains:";
24  for (it=mylist.begin(); it!=mylist.end(); ++it)
25    std::cout << ' ' << *it;
26  std::cout << '\n';
27
28  return 0;
29}