简单的容器操作问题
#include<iostream>
#include<list>
using namespace std;
void main()
{
int ia[11] = { 0, 1, 1, 2, 3, 5, 8, 13, 21, 55, 89 };
list<int> iList( ia, ia+11 );
list<int>::iterator it;
for ( it = iList.begin(); it != iList.end(); ++it )
{
if ( *it % 2 != 0 )
iList.erase( it );
}
cout << "OK" << endl;
for ( it = iList.begin(); it != iList.end(); it++ )
{
cout << *it << endl;
}
}
编译连接都无错误,可是执行的时候会莫名其妙的结束,请大家帮忙看看