C++ 编译报错discards qualifiers [-fpermissive]
声明了一个类
class Card
{
public:
Card(const string&);
int m_value;
char m_suit;
private:
const static map<char, int> m_map;
};
const map<char, int> Card::m_map=
{
{'2', 2},
{'3', 3},
{'4', 4},
{'5', 5},
{'6', 6},
{'7', 7},
{'8', 8},
{'9', 9},
{'T', 10},
{'J', 11},
{'Q', 12},
{'K', 13},
{'A', 14}
};
Card::Card( const string& p_cardVal)
{
//m_value = Card::m_map[(p_cardVal[0]];
m_value = Card::m_map.at(p_cardVal[0]);
m_suit = p_cardVal[1];
}
红线部分会报错,显示error: passing ‘const std::map<char, int>’ as ‘this’ argument discards qualifiers [-fpermissive]
查看CPP reference 可以知道,map的[],都是非const 的,而m_map是const的对象,于是会报错。(见http://blog.csdn.net/xidwong/article/details/52754514)
在map的成员函数中,at成员函数
C++ 编译报错discards qualifiers [-fpermissive]的更多相关文章
- 使用C#模拟Outlook发送邮件,代码编译报错
添加OutLook API using OutLook = Microsoft.Office.Interop.Outlook; 发送邮件方法 public void SendEmail() { Out ...
- cordova编译报错:Execution failed for task ':processDebugResources'
cordova编译报错:Execution failed for task ':processDebugResources' 引发这个错误的最扩祸首就是一个中文命名的文件,不知道什么时候加入的,我写了 ...
- 编译报错dereferencing pointer to incomplete type
关于编译报错“dereferencing pointer to incomplete type... 多是没找到结构体的定义,可以在本地复制其定义试试. 参考: http://my.oschina.n ...
- Maven-010-maven 编译报错:Failure to ... in ... was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced.
今晚在编译 maven 项目的时候,命令行报错,出现 Failure to ... in ... 类似错误,详细的错误信息如下所示: [INFO] -------------------------- ...
- [Intellij] 编译报错 javacTask
报错信息: Idea 编译报错 javacTask: 源发行版 1.6 需要目标发行版 1.6 解决方案:
- jenkis编译报错:需要class,interface或enum
现象: 1.jenkis编译报错:需要class,interface或enum 2.使用ant进行编译ok. 解决方法: 1. Jenkis重新编译一个以前成功的svn版本,直至编译成功. 2.Jen ...
- 对arm指令集的疑惑,静态库运行,编译报错等问题
转载自http://www.jianshu.com/p/4a70aa03a4ea?utm_campaign=hugo&utm_medium=reader_share&utm_conte ...
- xocde7下导入libsqlite3.tbd编译报错的解决办法
在xocde7下没有libsqlite3.dylib,只有libsqlite3.tbd,然后我导入了tbd.编译报错error: /Applications/Xcode.app/Contents/De ...
- 关于vue-clidown到本地后,拷贝文件库到另外一台电脑上npm run dev编译报错的处理
这些天自己在用vue-cli项目,在家里的电脑下下来后写了一些demo,拿到公司继续开发的时候发现删除node_modules文件,运行npm install和npm run 百度,搜狗了好久都没有找 ...
随机推荐
- java中map集合的迭代
import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class TestMap { pu ...
- WCF小试
1.创建WCF 右键解决方案-新建项目-WCF服务应用程序. 创建后会生成一些文件,其中IService.cs是服务的接口,只有在接口中定义的方法才能被外部调用,Service.svc是我们的服务名称 ...
- gulp折腾日记——gulp-livereload
大家好,虽然在博客园注册了很长一段时间,但我还没在博客园写过博客,这是在博客园的第一篇博客,希望能养成每周写博客的好习惯 O(∩∩)O~~) 今天要聊得是gulp的一个实时刷新的插件gulp-live ...
- iOS UI控件总结(全)
1.UIButton UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake ...
- ThinkPhp框架 分页 和session验证的使用
TP框架分页要使用到类文件,可以使用自己的类文件,也可以使用tp框架自带的类文件. 首先导入分页的类文件(Page.class.php): <?php namespace Home\shuju; ...
- Android px、dp、sp之间相互转换 系统默认12 sp
px 就是像素 sp=dpX字体比例(1.25f) 一.dp(或者dip device independent pixels) 一种基于屏幕密度的抽象单位.在每英寸160点的显示器上,1dp=1px ...
- Lucas定理学习(进阶中)
(1)Lucas定理:p为素数,则有: (2)证明: n=(ak...a2,a1,a0)p = (ak...a2,a1)p*p + a0 = [n/p]*p+a0,m=[m/p]*p+b0其次,我们 ...
- Class.getResourceAsStream()与ClassLoader.getResourceAsStream()的区别
Class.getResourceAsStream() 会指定要加载的资源路径与当前类所在包的路径一致. 例如你写了一个MyTest类在包com.test.mycode 下,那么MyTest.clas ...
- iOS开发之JSON & XML
1.概述 JSON (1) 作为一种轻量级的数据交换格式,正在逐步取代XML,成为网络数据的通用格式 (2) 基于JavaScript的一个子集 (3) 易读性略差,编码手写难度大,数据量小 (4) ...
- 不使用回调函数的ajax请求实现(async和await简化回调函数嵌套)
在常规的服务器端程序设计中, 比如说爬虫程序, 发送http请求的过程会使整个执行过程阻塞,直到http请求响应完成代码才会继续执行, 以php为例子 $url = "http://www. ...