[EC++_item3]任何可能的时候都使用const
2014-04-06 21:26
169 查看
Things to Rember
1.Declaring something const helps compilers detect usage errors. const can be applied to objects at
any scope, to function parameters and return types, and to member functions as a whole.
将某些东西声明为const可帮助编译器侦测出错误用法。const可被施加于任何作用域内的对象、函数参数、函数
返回类型、成员函数本体。
2.Compilers enforce bitwise constness, but you should program using conceptual constness.
编译器强制实施bitwise constness, 但你编写程序时应该使用“概念上的常量性”
3.When const and non-const member functions have essentially identical implementations, code
duplication can be avoided by having the non-const version call the const version.
当const和non-const成员函数有着实质等价的实现时,令non-const版本调用const版本可避免代码重复。
1.Declaring something const helps compilers detect usage errors. const can be applied to objects at
any scope, to function parameters and return types, and to member functions as a whole.
将某些东西声明为const可帮助编译器侦测出错误用法。const可被施加于任何作用域内的对象、函数参数、函数
返回类型、成员函数本体。
2.Compilers enforce bitwise constness, but you should program using conceptual constness.
编译器强制实施bitwise constness, 但你编写程序时应该使用“概念上的常量性”
3.When const and non-const member functions have essentially identical implementations, code
duplication can be avoided by having the non-const version call the const version.
当const和non-const成员函数有着实质等价的实现时,令non-const版本调用const版本可避免代码重复。
相关文章推荐
- 读书笔记 effective c++ Item 3 在任何可能的时候使用 const
- 使用navicat premium导入数据时候,可能出现导入异常
- 无线/移动通信的发展终极目标是,实现个人通信PCN是人类通信的最高目标,它指使用各种可能的网络技术,实现任何人在任何时间、任何地点与任何人进行任何何种类的信息交换。
- 安卓使用万能适配器时候不能再item布局最外层布局进行tag设置
- “应该为在运行时可能编辑的任何文本嵌入字体,具有”使用设备字体”设置的文本除外。使用”文本” > “字体嵌入”命令嵌入字体。”
- 牛腩购物 8 整合用户留言 动软生成器 ,.NET在后置代码中输入JS提示语句(背景不会变白),repeater 循环的时候事件判断,repeater 隔行 奇数行,item列,隐藏区块 Panel 的使用,前台绑定代码的时候使用函数
- 使用ajax返回json类型数据的时候无法进入success可能的原因
- 关于Entity Framework更新的几种方式以及可能遇到的问题(附加类型“Model”的实体失败,因为相同类型的其他实体已具有相同的主键值)在使用 "Attach" 方法或者将实体的状态设置为 "Unchanged" 或 "Modified" 时如果图形中的任何实体具有冲突键值,则可能会发生上述行为
- 使用listview的多种itemtype的时候的注意事项
- 一种语言, 适合任何时候使用 — Haxe特性杂谈
- Item4:Use const whenever possible--尽可能使用const
- 重读经典-《Effective C++》Item3:尽可能使用const
- struts(当我使用contentPage的时候提示我下载action)(让后我修改成pageEncoding)(可能是因为这一次引入啦新的jar包)
- 使用大量checkbox的时候可能出现的小问题
- 承租方在使用过程中,若违反本公司的有关规定,公司有权在任何时候收回车辆
- 使用Xcode 时候程序莫名其妙Build不过去的可能原因
- Item 15: 只要有可能,就使用constexpr
- Effective C++----3rd Edition, Item 3:尽可能使用const
- [EC++_item4]确定对象被使用前已先被初始化
- 2009年腾讯校园招聘笔试题! 不使用任何中间变量求一个const字符串长度