运动补偿 发表于 2005-4-17 09:54

关于C++中的STL的弱弱的问题。

关于我写了一个代码,想任意生成指定容量的序列式容器,
但不知道为什么,如果使用iterator的时候,如何进行插入操作。
#include <vector>
#include <list>
#include <deque>
#include <iostream>
#include <cstdlib>
using namespace std;

template<typename Iter>
Iter generate(Iter iter,int size)
{
if(size<=0) {cerr<<"Size is not correct"<<endl;return 0;}
srand(100);
for(int ix=0;ix<size;ix++)
{iter->insert(rand()%100);}///Something is wrong here!!!
return iter;
}
页: [1]
查看完整版本: 关于C++中的STL的弱弱的问题。