Mega Code Archive

 
Categories / C++ Tutorial / List
 

Inserting Elements in the List Using push_front

#include <list> #include <iostream> int main () {    std::list <int> listIntegers;    listIntegers.push_front (10);    listIntegers.push_front (2001);    listIntegers.push_front (-1);    listIntegers.push_front (9999);    std::list <int> ::iterator i;    for ( i = listIntegers.begin (); i != listIntegers.end (); ++ i )         std::cout << *i << std::endl;    return 0; }