Effective C++ 3. Use const whenever posible
来源:互联网 发布:淘宝卖家售假被扣48分 编辑:程序博客网 时间:2024/06/16 07:14
char operator[] (std::size_t position) { return text[position];}
tb[0] = ‘x’;
it is never legal to modify the return value of a function that return a built-in type.
mutable
class CTextBlock {public: ... std::size_t length() const; private: char *pText; mutable std::size_t textLength; mutable bool lengthIsValid;};std::size_t CTextBlock::length() const { if (!lenghtIsValid) { textLength = std::strlen(pText); lengthIsValid = true; } return textLength;}
class TextBlock {public: ... const char& operator[] (std::size_t position) const { ... return text[position]; } char& operator[] (std::size_t position) const { return const_cast<char&>(static_cast<const TextBlock&>(*this)[positon]); }};
阅读全文
0 0
- Effective C++ 3. Use const whenever posible
- 《Effective C++》读书笔记之三 Item 3. Use const whenever possible
- Item3: Use const whenever possible
- use const whenever you need
- 条款03:use const whenever possible
- Item 03 : Use const whenever possible.
- 条款03 use const whenever possible
- <Effective Modern C++>Item 15: Use constexpr whenever possible.[constexpr 表达式]
- Item4:Use const whenever possible--尽可能使用const
- 条款03:尽可能使用const(Use const whenever possible.)
- 条款03:尽可能使用const(Use const whenever possible.)
- 条款03:尽可能使用const(Use const whenever possible.)
- Item15 Use constexpr whenever possible
- 【Effective C++】const的使用
- whenever
- effective c++:条款21: 尽可能使用const
- 《Effective C++》读书笔记之const高效使用
- 【Effective C++】条款03-尽可能使用const
- ubuntu防火墙操作
- AndroidStudio 中开启Java8语法和Retrolambda库的使用
- 单链表的反转
- 如何新建java项目
- C++的标准输出和读写文件
- Effective C++ 3. Use const whenever posible
- 设计模式之二:Builder模式
- HDU-6019 MG loves gold
- ossec启动报ossec-remoted(1206): ERROR: Unable to Bind port错误解决方法
- Android中隐式跳转到系统设置界面(意图对象)
- (M)Backtracking: 93. Restore IP Addresses
- openjdk7 源码下载
- typora markdown 图片自动上传到图床
- CentOS7 yum 安装Mysql5.7