用C++ STL(标准模板库)编写仿函数的时候,编译报错:
error: passing 'const FindNameOrAddress' as 'this' argument of 'bool FindNameOrAddress::operator()(std::string, std::string)' discards qualifiers [-fpermissive]
其中:FindNameOrAddress 为类名。在使用STL中的某些算法的时,有时候出于需要,不得不自己去实现函数对象,然后再用适配器来绑定并匹配函数参数问题。

//函数适配器 bind1st  bind2nd ,二元函数对象需要继承binary_function<参数类型,参数类型,返回值类型>;
//若为一元函数对象,则需继承unary_function
struct FindNameOrAddress : public std::binary_function<std::string,std::string, bool>
{bool operator()(const std::string stuA,const std::string stuB){return strncmp(stuA.c_str(),stuB.c_str(),stuA.length())?true:false;//可以直接 return  stuA>stuB?true:false;}
};

上面的类编译就会报错,因为我们在进行括号"()"重

C++ STL编译报错:error: error passing 'const' as 'this' argument相关推荐

  1. 关于 Visual stdio 编译报错:error MSB6006: “CL.exe”已退出

    网上查看,原因有多种. 我自己遇到的是这样的: 环境:VS2019,编译项目 image-master,中间自己重整了原来的目录,移动了很多文件.编译报错:error MSB6006: "C ...

  2. 【c语言 gcc9.1.0环境下编译报错】error: ‘true’ undeclared (first use in this function)

    问题 网上验证一个单链表是否有环的c语言demo,放到gcc9.1.0的环境下编译,发现编译报错: error: 'true' undeclared (first use in this functi ...

  3. 编译报错:error: ro.build.fingerprint cannot exceed 91 bytes

    编译报错:error: ro.build.fingerprint cannot exceed 91 bytes Notice file: system/core/libzipfile/NOTICE - ...

  4. bison版本问题导致编译报错:‘parse.error‘ is not used

    bison版本问题导致编译报错:'parse.error' is not used 'parse.error' 问题定位和修正 问题发现 问题调查与定位 更新bison/flex版本 问题修正 一些参 ...

  5. idea编译报错:Error:Kotlin: Module was compiled with an incompatible version of Kotlin.

    1. idea 编译报错信息 Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary ...

  6. php baocuo error,PHP编译报错configure: error: Cannot find libmysqlclient under /usr.

    今天编译PHP的时候遇到了几个错误,记录一下 第一次编译的时候报错如下: configure: error: mcrypt.h not found. Please reinstall libmcryp ...

  7. STM8L151的IAR工程编译报错Fatal Error[Pe035]: #error directive: “Please select first the target STM8L...

    项目场景: STM8L151G4XX单片机IAR工程编译报错. 问题描述 编译报错:Fatal Error[Pe035]: #error directive: "Please select ...

  8. kylin系统gcc编译报错fatal error:stadio.h: 没有那个文件或目录解决办法

    在进行内存容量极限测试时,出现编译报错如下: $sudo gcc eat-memory.c -o eat-memory eat-memory.c:1:10: fatal error: stdio.h: ...

  9. linux c 编译报错 Compile error : undefined reference to‘__atomic_fetch_add_4’ 解决方法

    代码如下: #include <opencv2/opencv.hpp> using namespace cv;int main() {Mat img=imread("cornea ...

最新文章

  1. Android初步学习BroadCast与Service实现简单的音乐播放器
  2. Boost库实现线程池学习及线程实现的异步调用
  3. [2020.11.27NOIP模拟赛]拼图王【dp】
  4. 在Js或者cess后加版本号 防止浏览器缓存
  5. pandas dataframe创建_Python数据分析基础之Pandas学习 (上)
  6. Elasticsearch安装-源码
  7. android 修改listview item view 的方法
  8. Vue中data数据变化 -- 页面重新渲染的问题
  9. 乔布斯鲜为人知的私生活:低调、曾经多情
  10. 操作系统安装磁盘清理方法
  11. 获利能力分析实际数据收集流程
  12. YiGo学习(一)YiGo介绍
  13. 网易2018实习生招聘笔试题的收获
  14. 证券行业的数字化转型:数字新基建 (云、中台、数字化解决方案)
  15. Batch和Epoch之间的区别是什么?
  16. Allegro PCB 图纸大小及坐标原点位置
  17. 论文研读:Operating System Support for NVM+DRAM Hybrid Main Memory
  18. p2psearcher4.0 绿色版下载
  19. python数据类型详解及类型转换函数
  20. 一些Vim有用的配置

热门文章

  1. java练习:编写工资系统,实现不同类型员工(多态)的按月发放工资。如果当月出现某个Employee对象的生日,则将该雇员的工资增加100元。
  2. NODE.JS怎么给手机发短信对接验证码短信接口DEMO示例
  3. 绝地求生2月26服务器维护吗,绝地求生2月26日维护更新内容 绝地求生2月26日更新了什么...
  4. Genymotion无法添加虚拟手机设备解决方式
  5. Unity 小米VR一体机开发(二)
  6. 恢复损坏的pdf文件
  7. @Maven pom.xml标配
  8. mysql初始密码的获取以及修改超级用户密码的方法
  9. 瞄准C端,「叮咚买菜」能否成为“预制菜”破局者?
  10. 笔记本玩逆水寒服务器未响应,逆水寒游戏运行时电脑崩溃怎么办_逆水寒运行游戏是笔记本崩溃问题解决办法介绍_游戏吧...