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

[求助]一小段程序编译无法通过,求教

dyc9422 发布于 2007-05-20 09:57, 541 次点击

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

int main()
{
char* sa[]={"Marry","Tom","Bob","Alice"};
list<char*>slst(sa,sa+4);
vector<string>svec;
string str;
svec.assign(slst.begin(),slst.end());
return 0;
}

如上,红色标注行出错,我是按书上打的,为什么会编译出错,求教。谢谢。。

5 回复
#2
yuyunliuhen2007-05-20 13:09
程序没有错,在G++下通过,我想你用VC++6.0的吧
#3
icedge2007-05-20 13:58
vc2005编译也是成功的,没有错误或警告。
#4
dyc94222007-05-20 17:50
呵呵,原来是这样。。我说呢,是用VC++6.0的,感谢版主和icedge的回复。。
那是不是装个G++编译器。或vc2005,就可以编译通过和运行了呢。。
#5
icedge2007-05-20 18:46
换个编译器应该可以,我觉得bcb6.0也不错,教材里说vc6.0不是标准c++,所以我就换了2005了。
#6
dyc94222007-05-21 06:38

嘿嘿。。用G++的通过运行了。。
我用的是DEV C++,在网上搜了下,ok了。。

1