- C
- Object-Oriented C++
- Template C++
- STL
class GamePlayer{
private:
static const int NumTurns=5;
//测试编译器是否支持
int scores[NumTurns];
....
};
条款03:尽可能使用const
- 将某些东西声明为const可以帮助编译器侦测出错误用法
- 编译器强制实施bitwise constness,但你编写程序时应该使用“概念上的常量性”(conceptual constness)
- 当const和non-const成员函数有着实质等价的实现时,令non-const版本调用const版本可避免代码重复



