Effective C++ 18. Make interfaces easy to use correctly and hard to use incorrectly
2017-10-26 16:41
537 查看
Class Month { public: explicit Month() { month = m; } private: int month; }; Month Jan(Month(1));
// in other file extern Month Jan; Data d(Jan, Day(30), Year(1995)); // wrong! unless Jan is initialized before d defined
class Month { public: static Month Jan() { return Month(1); } private: explicit Month(int m); }; Date d(Month::Jan(), Day(30), Year(1995));
相关文章推荐
- Effective C++ Item 18 Make interfaces easy to use correctly and hard to use incorrectly
- effective c++ 条款18 make interface easy to use correctly and hard to use incorrectly
- Item 18: Make interfaces easy to use correctly and hard to use incorrectly(Effective C++)
- 条款18:让接口容易被正确使用,不易被误用(Make interface easy to use correctly and hard to use incorrectly)
- Make Interfaces Easy to Use Correctly and Hard to Use Incorrectly
- Make Interfaces Easy to Use Correctly and Hard to Use Incorrectly
- Item21 Perfer std::make_unique and std::make_shared to direct use of new
- The most simple and easy to use Qt GUI library plug-in FTStyle (3)How do Qt4 and Qt5 choose
- Easy way to use JText 2.1.7 and HTML-style template for generating report
- Chinese version QQ—how to install it and use it to make a audio call and video call
- Easy way to use JText 2.1.7 and HTML-style template for generating report
- When to use comparable and comparator interfaces in java
- Sodium: A Modern and Easy-to-Use Crypto Library
- I learned several ASP.NET's AJAX ability today! It is so interesting and so easy to use AJAX in ASP.NET.
- Input and Output(easy to use)
- How to Correctly and Uniformly Use Progress Monitors
- The most simple and easy to use Qt GUI library plug-in FTStyle (1)
- Android Run Time: An Easy Hack To Make Your Phone Faster And Its Battery Last Longer
- how to write your annotation types and make use of built-in annotations to control their behavior
- The most simple and easy to use Qt GUI library plug-in FTStyle (2)The latest version - 2017.10