注册 登录
编程论坛 C++教室

list<char*>和vector<string>容器使用assign在VC运行出错

renhao153 发布于 2008-09-06 23:46, 1504 次点击
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include<deque>
#include<algorithm>

using namespace std;
void main()
{
    list<char*> cd;
    char df[2][3];
    for(int i=0;i<2;++i)
    {
        cin>>*(df+i);
        cd.push_front (*(df+i));
    }

    vector<string> er;
    er.assign(cd.begin(),cd.end());
}
E:\电子图书\VC制作\C测试\cs1.cpp(20) : error C2664: 'void __thiscall std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,
class std::allocator<char> > > >::assign(const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *,const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)' : cannot conve
rt parameter 1 from 'class std::list<char *,class std::allocator<char *> >::iterator' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *'
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
急求高手解释一下原因
4 回复
#2
xyt_bluesky2008-09-07 10:15
我运行了一下,貌似没有错误。在我的编译系统上能运行。不过我用的编译系统是VC9.0的
#3
renhao1532008-09-07 10:41
回复 2# xyt_bluesky 的帖子
我的是vc++6.0运行出错了
#4
晓之风2009-08-05 11:10
我也是这样!哎!不知道怎么解决呀!
#5
cedricporter2009-08-05 12:38
我的也可以呃............VC8....
1