difference between push_back() and push_front() : list push pop « list « C++ Tutorial






#include <iostream>
#include <list>
using namespace std;
   
int main()
{
  list<int> lst1, lst2;
  int i;
   
  for(i=0; i<10; i++) lst1.push_back(i);
  for(i=0; i<10; i++) lst2.push_front(i);
 
  list<int>::iterator p;
 
  p = lst1.begin(); 
  while(p != lst1.end()) {
    cout << *p << " ";
    p++;
  }
   
  p = lst2.begin(); 
  while(p != lst2.end()) {
    cout << *p << " ";
    p++;
  }
   
  return 0;
}








17.11.list push pop
17.11.1.list: push_back and push_front
17.11.2.list: push_back, front, empty and pop_front
17.11.3.Add some data by push_front
17.11.4.Demonstrating the difference between push_back() and push_front()
17.11.5.list.pop_front(): remove element from front
17.11.6.difference between push_back() and push_front()
17.11.7.list.pop_back(): remove element from back