STl::list中的插入操作!向我开炮吧!
[code=C/C++][/code]
#include <vector>
#include <list>
#include <iostream>
using namespace std;
int main()
{vector<int> v1(10,250);
vector<int>::iterator pv;
pv=v1.begin();
list<int> l1(pv,pv+5);
list<int>::iterator pl;
for(pl=l1.begin();pl!=l1.end();pl++)
{
cout<<*pl<<'\t';
}
pl=l1.begin();
cout<<endl<<"1:"<<endl;
l1.insert(pl++,l1.begin(),l1.end());
for(pl=l1.begin();pl!=l1.end();pl++)
{
cout<<*pl<<'\t';
}
cout<<"2:"<<endl;
pl=l1.begin();
l1.insert(pl,pl++,l1.end());
for(pl=l1.begin();pl!=l1.end();pl++)
{
cout<<*pl<<'\t';
}
cout<<endl;
return 0;
}
问题描述:第二个插入操作为什么不能成功,当按下ctrl+c后会产生一个异常。
静待大牛前来!
[解决办法]
没仔细看代码,不过VS2008编译没有问题。
250 250 250 250 2501:250 250 250 250 250 250 250 250 250 2502:250 250 250 250 250 250 250 250 250 250250 250 250 250 250 250 250 250 250 250Press any key to continue . . .
[解决办法]
GCC测试的结构也是一样的。