12.18

Posted lefthook

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了12.18相关的知识,希望对你有一定的参考价值。

Effective C++ Scott Meyers  

Chapter 1. Uses and Abuses of vector

1. Item 4: Make sure that objects are initialized before they‘re used.

  Use member initialization list to initialize the member.

  Sometimes, the initialization list must be used, even for built-in types. For example, data members that are const or are references must be initialized.

  Always list members in the initialization list in the same order as they‘re declared in the class.

  When class has multiple constructors, omit the entries in the list for data members where assignment works as well as true initialization, moving the assignments to a single function that all the constructors call.

  Static objects declared inside functions are known as local static objects, and the other kinds of static objects are known as non-local static objects.

  The relative order of initialization of non-local static objects defined in different translation units is undefined.

  Define the non-local static objects in local functions, where it‘s declared static. These functions return references to the objects they contain. (Singleton Pattern)

  The functions contain static objects makes them problematic in multithreaded systems. One way to deal with it is to manually invoke all the reference-returning functions during the single-threaded startup portion of the program. This eliminates initialization-related race conditions.

以上是关于12.18的主要内容,如果未能解决你的问题,请参考以下文章

12.18

12.18战略会议

PHP课后小结 12.18

Sprint3(12.18)总结

12.18语法制导的语义翻译

About 12.18 This Week