免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4216 | 回复: 3
打印 上一主题 下一主题

[C++] 为什么提示没有max库 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2018-04-11 09:34 |只看该作者 |倒序浏览
编译代码提示错误,提示max函数没有声明,但是已经#include  <alogrithm>了 不理解,请高人指点。
  

  double max_setij_so_far() const {
    double max_setij = setij();
    std::vector<T*> my_ori = parents();
    for (size_t  i = 0; i < my_ori.size(); ++i)
      max_setij = max(max_setij, my_ori[i]->max_setij_so_far());
    return max_setij;
  }


错误提示如下
error: ‘max’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
       max_setij = max(max_dij, my_parents[i]->max_dij_so_far());

/usr/include/c++/4.8.3/bits/stl_algobase.h:260:5: note: ‘template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ declared here, later in the translation unit
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^

##################
默认的stl_algobase.h 模版我没有修改过  但似乎程序调用系统stl里的max不认识 正常应该可以直接去调用   max(const _Tp& __a, const _Tp& __b)阿,请指点
编译器是gcc 4.8.3

是不是my_ori[i]->max_setij_so_far() 需要重新定义一个量呢


论坛徽章:
12
2015年辞旧岁徽章
日期:2015-03-03 16:54:1515-16赛季CBA联赛之同曦
日期:2017-03-17 19:13:162016科比退役纪念章
日期:2016-11-07 08:28:12luobin
日期:2016-06-17 17:46:36wusuopu
日期:2016-06-17 17:43:4515-16赛季CBA联赛之福建
日期:2016-01-14 12:49:22程序设计版块每日发帖之星
日期:2015-12-13 06:20:00程序设计版块每日发帖之星
日期:2015-06-08 22:20:00程序设计版块每日发帖之星
日期:2015-06-08 22:20:002015年亚洲杯之科威特
日期:2015-03-24 14:21:272015年迎新春徽章
日期:2015-03-04 09:57:092016科比退役纪念章
日期:2018-04-10 16:20:18
2 [报告]
发表于 2018-04-11 09:39 |只看该作者
代码贴的不全;可以试试 std::max;

论坛徽章:
12
2015年辞旧岁徽章
日期:2015-03-03 16:54:1515-16赛季CBA联赛之同曦
日期:2017-03-17 19:13:162016科比退役纪念章
日期:2016-11-07 08:28:12luobin
日期:2016-06-17 17:46:36wusuopu
日期:2016-06-17 17:43:4515-16赛季CBA联赛之福建
日期:2016-01-14 12:49:22程序设计版块每日发帖之星
日期:2015-12-13 06:20:00程序设计版块每日发帖之星
日期:2015-06-08 22:20:00程序设计版块每日发帖之星
日期:2015-06-08 22:20:002015年亚洲杯之科威特
日期:2015-03-24 14:21:272015年迎新春徽章
日期:2015-03-04 09:57:092016科比退役纪念章
日期:2018-04-10 16:20:18
3 [报告]
发表于 2018-04-11 09:39 |只看该作者
代码贴的不全;可以试试 std::max;

论坛徽章:
0
4 [报告]
发表于 2018-04-11 10:28 |只看该作者
代码很大的一个包 难贴全阿
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP