问高手们,一个简单程序的问题
#include <vector>
#include <iostream>
#include <string>
using namespace std;
vector<string> iter;
vector<string>::iterator ite = iter.begin();
void download(int);
int main()
{
iter.push_back("111111");
iter.push_back("222222");
vector<string>::iterator ite_end = iter.end();
int i=0;
while(ite!=ite_end)
{
download(i);
ite_end = iter.end();
ite++;
i++;
}
iter.clear();
return 1;
}
void download(int i)
{
if (i%2==0)
iter.push_back("11111111");
}
为什么一运行就死机呢?能分析下原因吗?
如何实现动态的增加容器内容,并且动态的访问呢?