#include <iostream>
#include <vector>
#include <list>
#include <string>
using namespace std;
int main(int argc,char *argv[])
{
char *sa[] = {"Yulingui","zhouyujia","gouyongpan","sunlin"};
list<char*> clist(sa,sa+4);
vector<string> svec;
string str;
/*将list对象中的所有元素赋值给vector对象*/
svec.assign(clist.begin(),clist.end());
/*输出list对象中的所有元素*/
for (list<char*>::iterator lit=clist.begin();lit!=clist.end();
++lit)
{
cout<<*lit<<" ";
}
cout<<endl;
/*输出vector对象中的所有元素*/
for(vector<string>::iterator vit=svec.begin();vit!=svec.end();
++vit)
{
cout<<*vit<<" ";
}
cout<<endl;
return 0;
}
|