关于顺序容器类的复制问题
书上说顺序容器的assign(b,e)操作可以在不同类型的容器间复制
为什么我这么用就不行呢
到底能不能在不同类型的容器间复制呢?
#include <iostream>
#include <vector>
#include <list>
#include <string>
using namespace std;
int main()
{
vector <string> names;
string name;
while(cin> > name&&name!= "# ")
{
names.push_back(name);
}
vector <string> ::iterator head=names.begin();
vector <string> ::iterator last=names.end();
while(head!=last)
{
cout < <*head < <endl;
head++;
}
head=names.begin();
last=names.end();
list <string> lnames;
lnames.assign(head,last);
list <string> ::iterator lhead=lnames.begin();
list <string> ::iterator llast=lnames.end();
while(lhead!=llast)
{
cout < <*lhead < <endl;
lhead++;
}
return 0;
}
[解决办法]
你用的VC6?早点扔了,换vc2005,devcpp,不要用VC6浪费生命了。
[解决办法]
是不是编译器不同 标准就不同了
=====================
不能这么说,关键是VC6已经向市场发布的时候,C++新标准才刚刚定出来,所以你不能怪它,要怪只能怪你竟然在2007年还用它,嘿嘿。