I have two lists and what I want to do is to insert some of the elements in the middle of one of the lists into another.
Does anyone have any ideas why this piece of code does not compile?
if on Line 13, I use comNode.bgin() instead of comNode.begin()+1 the coude compiles perfectly though.
Thank you for your help!
#include<iostream>
#include<list>
using namespace std;
int main()
{
list<int> comNode;
list<int> erased;
comNode.push_front(10);
comNode.push_front(100);
comNode.push_front(1000);
comNode.push_front(10000);
erased.insert (erased.end (),
comNode.begin()+1,
comNode.end ());
std::list <int>::const_iterator listLocator;
for (listLocator = erased.begin();
listLocator!=erased.end();
listLocator++)
cout << *listLocator << endl;
return 0;
}
This post has been edited by machoolah: 27 July 2009 - 04:49 PM

New Topic/Question
Reply




MultiQuote




|