
C/C++
文章平均质量分 83
yulefox
这个作者很懒,什么都没留下…
展开
-
细读《Effective C++》之十四
Chapter 8. Customizing new and delete正如C#、JAVA声称自己的内置“垃圾回收能力”一样,C++则以其高效的“手动回收”著称。Scott提到heap资源在多线程编程时的访问问题,引起了我的兴趣。Item 49 - 52条款49:Understand the behavior of the new-handleroperator new失败时将执原创 2007-06-21 07:02:00 · 1474 阅读 · 1 评论 -
细读《Effective C++》之十二
Chapter 7. Templates and Generic ProgrammingItem 43 - 44条款43:Know how to access names in templatized base classes下面的code是无法通过编译的:templatetypename Company>class LoggingMsgSender: public MsgSe原创 2007-05-30 00:39:00 · 1188 阅读 · 0 评论 -
细读《Effective C++》之十一
Chapter 7. Templates and Generic ProgrammingScott在Item 01里面就列举出了C++中的四种所谓“sublanguages”:C、OO C++、Template C++、STL。前面的Items一直评论的是OO C++,这一章则主要针对Template C++。Item 41 - 42条款41:Understand implicit i原创 2007-05-28 00:34:00 · 1246 阅读 · 0 评论 -
细读《Effective C++》之九
Chapter 6. Inheritance and Object-Oriented Design 条款36:Never redefine an inherited non-virtual functionclass B {public: void mf(); ...};class D: public B {public: void mf(); ... };D原创 2007-05-15 11:37:00 · 1190 阅读 · 0 评论 -
细读《Effective C++》之八
Chapter 6. Inheritance and Object-Oriented Design Item 35条款35:Consider alternatives to virtual functions当我辛辛苦苦用virtual functions提供了接口和缺省实现之后,Scott却提出考虑其它解法……需求是什么来着?GoF认为类行为模式Template Me原创 2007-05-12 01:14:00 · 1155 阅读 · 0 评论 -
细读《Effective C++》之六
Chapter 5. ImplementationsItem 29 - 31条款29:Strive for exception-safe codevoid PrettyMenu::changeBackground(std::istream& imgSrc)...{ lock(&mutex); // acquire mutex (as in原创 2007-05-10 00:26:00 · 1129 阅读 · 0 评论 -
细读《Effective C++》之五
Chapter 5. Implementations如果说对于对象模型的深刻理解是为了更好地设计和声明,那么对于实现的斤斤计较则是为了更高的效率。Item 26 - 28条款26:Postpone variable definitions as long as possible不要过早地定义变量,直到真正需要它;对于非build-in对象,能够用copy constructor替代原创 2007-05-08 00:40:00 · 1105 阅读 · 0 评论 -
细读《Effective C++》之四
Chapter 4. Designs and Declarations什么样的接口是你应该提供给client的?或者,换句话说:什么样的接口是你希望被提供的?If an attempted use of an interface wont do what the client expects, the code wont compile; and if the code does co原创 2007-05-02 09:52:00 · 1113 阅读 · 0 评论 -
细读《Effective C++》之三
Chapter 3. Resource ManagementScott说:这儿的resource包括dynamically allocated memory、file descriptors、mutex locks、GUI objects、database connections和network sockets。“拿了我的给我还回来,吃了我的给我吐出来”……Item 13 - 17原创 2007-04-23 00:51:00 · 1137 阅读 · 0 评论 -
细读《Effective C++》之二
第二章 Constructors, Destructors, and Assignment Operators这一章内容参考Stanley B. Lippman的《Inside the C++ Object Model》也会有不小的收获。条款05:Know what functions C++ silently writes and calls在最早接触C++的class的时候,你就被原创 2007-04-19 15:41:00 · 1511 阅读 · 0 评论 -
细读《Effective C++》之十三
Chapter 7. Templates and Generic Programmingtemplates的一个最重要的作用在于让很多原来在运行期的工作提前到编译期间完成。Item 41:templates和classes一样都是支持interfaces和polymorphics的,而且tempaltes支持implicit interfaces和compile-time polymorp原创 2007-06-05 16:08:00 · 1303 阅读 · 0 评论