为什么编译过不去?

flyccloud 2003-11-30 04:17:40
这段是Bjarne Stroustrup 的<<C++程序设计语言>>中的一段程序,
头文件都include 了

int main(int argc, char* argv[])

{
string from, to;
cin>>from>>to;

ifstream is(from.c_str());
istream_iterator<string> ii(is);
istream_iterator<string> eos;

vector<string> b(ii,eos);

sort(b.begin(),b.end());

ofstream os(to.c_str());
ostream_iterator<string> oo(os, "\n");

unique_copy(b.begin(),b.end(),oo);

return !is.eof()||!os;
}
vector<string> b(ii,eos);这句话为什么报错,好象是类型不对?如何转换?
原文是int main()我用了控制台框架,有区别吗?
谢谢大家
...全文
49 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyccloud 2003-11-30
  • 打赏
  • 举报
回复
看来是VC 6.0的事了,结贴了
flyccloud 2003-11-30
  • 打赏
  • 举报
回复
hehe,我用了VC中 win32 console 的框架,向导自动生成的。没直接用int main
winco 2003-11-30
  • 打赏
  • 举报
回复
#include "string"
#include "iostream"
#include "vector"
#include "algorithm"
#include "fstream"

using namespace std;

int main(int argc, char* argv[])

{
string from, to;
cin>>from>>to;

ifstream is(from.c_str());
istream_iterator<string> ii(is);
istream_iterator<string> eos;

vector<string> b(ii,eos);

sort(b.begin(),b.end());

ofstream os(to.c_str());
ostream_iterator<string> oo(os, "\n");

unique_copy(b.begin(),b.end(),oo);


return !is.eof()||!os;
}

我得VC.NET没有错误
hcj2002 2003-11-30
  • 打赏
  • 举报
回复
不知道具体原因
顺便说一下int main(int argc, char* argv[])
是c风格的main函数,C++的应该是int main(void)

flyccloud 2003-11-30
  • 打赏
  • 举报
回复
一样的,报一个类型转换的错误,是不是VC不支持呀?
heguobaoceo 2003-11-30
  • 打赏
  • 举报
回复
可能是你在定义VECTOR的时候应该先定义类,再定义对象
    应该是下面的形式:
    typedef vector<string> CECTOR_STRING
   ........

     CECTOR_STRING b(ii,eos)应该没有错误了

24,855

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧