快乐小白兔 2014-04-25 09:14 采纳率: 33.3%
浏览 3654

在c++中,在流迭代器中使用sort报错

代码如下:
std::istream_iterator sii(std::cin),eof;
std::ostream_iterator oii(std::cout," ");
std::sort(sii,eof);//该行代码报错

//错误如下:

错误 2 error C2784: “'unknown-type' std::operator -(std::move_iterator<_RanIt> &,const std::move_iterator<_RanIt2> &)”: 未能从“std::istream_iterator<_Ty>”为“std::move_iterator<_RanIt> &”推导 模板 参数 e:\vs2012安装\vc\include\algorithm 3702 1 ConsoleApplication3
错误 3 error C2784: “'unknown-type' std::operator -(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)”: 未能从“std::istream_iterator<_Ty>”为“const std::reverse_iterator<_RanIt> &”推导 模板 参数 e:\vs2012安装\vc\include\algorithm 3702 1 ConsoleApplication3
错误 4 error C2784: “'unknown-type' std::operator -(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)”: 未能从“std::istream_iterator<_Ty>”为“const std::_Revranit<_RanIt,_Base> &”推导 模板 参数 e:\vs2012安装\vc\include\algorithm 3702 1 ConsoleApplication3
错误 6 error C2780: “void std::_Sort(_RanIt,_RanIt,_Diff,_Pr)”: 应输入 4 个参数,却提供了 3 个 e:\vs2012安装\vc\include\algorithm 3702 1 ConsoleApplication3
错误 5 error C2676: 二进制“-”:“std::istream_iterator<_Ty>”不定义该运算符或到预定义运算符可接收的类型的转换 e:\vs2012安装\vc\include\algorithm 3702 1 ConsoleApplication3

  • 写回答

1条回答 默认 最新

  • 笑遍整个世界 2014-05-15 12:43
    关注

    我简单写了一段代码,作用是将输入的字符串直接输出,可以说明你出现的问题:

    copy( istream_iterator< string >( cin ), istream_iterator< string >(), ostream_iterator< string >( cout, " " ) );

    你的问题是:输入输出流的类型是什么??我上面的代码是std::string.没有类型,当然出错.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配