标题:[求助]c++问题!(c++ primer 4 的课后题)
只看楼主
wdtk
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2007-10-10
 问题点数:0 回复次数:6 
[求助]c++问题!(c++ primer 4 的课后题)

//用list 中的元素 初始化 vector !!
#include<iostream>
#include<list>
#include<vector>
#include<string>
using namespace std;

int main()
{
char *arr[11]={"mary","lida","limeng","wangdogn","fengling"};
list<char*>clist(arr,arr+5);
vector<string>svec;
string str;
svec.assign(clist.begin(), clist.end()); //无法通过编译( vc++ 6.0)
for(list<char*>::iterator iter=clist.begin();iter!=clist.end();++iter)
cout<<*iter<<endl;
cout<<" "<<endl;
for(vector<string>::iterator iter1=svec.begin();iter1!=svec.end();++iter1)
cout<<*iter1<<endl;
return 0;
}

搜索更多相关主题的帖子: primer arr vector include 
2007-10-13 13:45
栖柏
Rank: 2
等 级:论坛游民
威 望:3
帖 子:1103
专家分:17
注 册:2007-8-23
得分:0 
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

You have lots more to work on! Never give up!c language!
2007-10-13 15:04
栖柏
Rank: 2
等 级:论坛游民
威 望:3
帖 子:1103
专家分:17
注 册:2007-8-23
得分:0 

建议换个编译器
用dev-cpp可以通过


You have lots more to work on! Never give up!c language!
2007-10-13 15:30
栖柏
Rank: 2
等 级:论坛游民
威 望:3
帖 子:1103
专家分:17
注 册:2007-8-23
得分:0 

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

int main()
{
char *arr[11]={"mary","lida","limeng","wangdogn","fengling"};
list<char*> clist(arr,arr+5);
vector<string> svec;
string str;
svec.assign(clist.begin(),clist.end()); //无法通过编译( vc++ 6.0)
for(list<char*>::iterator iter=clist.begin();iter!=clist.end();++iter)
cout<<*iter<<endl;
cout<<" "<<endl;
for(vector<string>::iterator iter1=svec.begin();iter1!=svec.end();++iter1)
cout<<*iter1<<endl;
cin.get();
return 0;
}
可以在dec-c++运行通过


You have lots more to work on! Never give up!c language!
2007-10-13 15:33
wdtk
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2007-10-10
得分:0 

哦,但我搞不清楚原因所在啊~~~!

2007-10-13 18:38
wdtk
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2007-10-10
得分:0 
回复:(栖柏)#include#include
但我搞不清楚原因所在啊~~!
2007-10-13 18:38
栖柏
Rank: 2
等 级:论坛游民
威 望:3
帖 子:1103
专家分:17
注 册:2007-8-23
得分:0 

在VC中的头文件里没有定义,需要你自己写
还是用dev -C++吧,对标准支持好些


You have lots more to work on! Never give up!c language!
2007-10-14 11:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-177277-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019349 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved