Original Post
I'm having a difficult time understanding how these functions work on linked lists, deques and vectors. I was hoping someone would look at the code below for me. Although pop_front and pop_back are not implemented below, I would like to know how they work as well. I realize that these 4 functions are involved in the inserting and deleting of data from a list, but I don't understand the process. I'd appreciate any help. Thanks, Dave
// list.cpp
#include <list>
#include <iostream>
using namespace std;
void OutputList(list<int> output)
{
list<int>::iterator pos;
for(pos = output.begin(); pos != output.end(); ++pos)
cout << *pos << " ";
cout << endl << endl;
}
int main()
{
list<int> mylist;
list<int>::iterator pos;
for(int a = 0; a <= 10; a++)
{
mylist.push_back(a * 2);
if(a) mylist.push_front(a * -2);
}
cout << "Even numbers from -20 to 20" << endl;
OutputList(mylist);