首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

顺序器皿中assign函数报错是为什么

2013-01-01 
顺序容器中assign函数报错是为什么#include iostream#include string#include vector#include list

顺序容器中assign函数报错是为什么


#include <iostream>
#include <string>
#include <vector>
#include <list>
using namespace std;

int main(){
char* sa[] = {"Mary", "Tom", "Bob", "Alice"};
list<char*> slst(sa, sa+4);
vector<string> svec;
string str;

svec.assign(slst.begin(), slst.end());

for(list<char*>::iterator lit = slst.begin();
lit != slst.end(); ++lit){
cout << *lit << " ";
}
cout << endl;

for(vector<string>::iterator vit = svec.begin(); 
vit != svec.end(); ++vit){
cout << *vit << " ";
}
cout << endl;

return 0;
}

代码中下面这一行报错是因为什么呢?
svec.assign(slst.begin(), slst.end());
将此行屏蔽就是好的
[解决办法]
LZ是不是还在用VC6?(因为别的帖子也是VC6的问题)
学习STL(标准C++)不要用VC6,它太老了,有它的时候还没有标准C++呢。

热点排行