读书笔记 Effective C++: 04 设计与声明
摘要:
条款18:让接口容易被正确使用,不易被误用1. 类型安全性 枚举enum并不具备类型安全性,可以当作int型使用,可采用类内static函数方式实现。class Month{public: static Month Jan(){return Month(1);} static Month Feb(){return Month(2);} ... static Month Dec(){return Month(12);}private: explicit Month(int m);};使用类内static函数,而不是static变量,主要是non-local static对象的初始化次... 阅读全文
posted @ 2013-04-25 22:48
LeaGem
阅读(176)
评论(0)
推荐(0)
浙公网安备 33010602011771号