- 线程池是线程的更高层的抽象
- 更容易扩展
- ++编码规范不鼓励异常,除非已有项目/底层库使用了异常,这时候必须要catch所有异常
- C++11 通过enable_if 可以实现重载返回值
- include 的头文件保持代码目录
- 如果每个成员函数都需要访问成员变量(以每个函数访问成员变量的个数作为判断标准),那么类就是高内聚的
- Scope operator, when the scope operator has an empty left-hand side, it is a request to fetch the name on the right-hand side from the global scope
- The identifiers we define in our own programs may not contain two consecutive underscores, nor can an identifier begin with an underscore followed immediately by an uppercase letter. In addition, identifiers defined outside a function may not begin with an underscore.
-
The value (i.e., the address) stored in a pointer can be in one of four states:
- It can point to an object.
- It can point to the location just immediately past the end of an object.
- It can be a null pointer, indicating that it is not bound to any object.
- It can be invalid; values other than the preceding three are invalid.
-
Our recommendation to initialize all variables is particularly important for pointers. If possible, define a pointer only after the object to which it should point has been defined. If there is no object to bind to a pointer, then initialize the pointer to nullptr or zero. That way, the program can detect that the pointer does not point to an object.
-
Reference is not an object. Once we have defined a reference, there is no way to make that reference refer to a different object. When we use a reference, we always get the object to which the reference was initially bound. There is no such identity between a pointer and the address that it holds. As with any other (nonreference) variable, when we assign to a pointer, we give the pointer itself a new value. Assignment makes the pointer point to a different object
-
Any nonzero pointer evaluates as true in condition.
-
To understand complicated pointer or reference declarations which read them from right to left.
-
Two exceptions to the rule that the type of a reference must match the type of the object to which it refers.
- Reference to const
-
Two exceptions to the rule that the types of a pointer and the object to which it points must match
- Pointer to const to point to a nonconst object
- To share a const object among multiple files, you must define the variable as extern
- there are no const references. A reference is not an object, so we cannot make a reference itself const. Indeed, because there is no way to make a reference refer to a different object, in some sense all references are const.
- const in reference types is always low-level
- It can be easier to understand array declarations by starting with the array’s name and reading them from the inside out.
- To use a multidimensional array in a range for, the loop control variable for all but the innermost array must be references
- 动态库 静态库
- References "rvalue reference" "lvalue reference"
- void * pointer
- Code inside headers ordinarily should not use using declarations.
- The value of an object of built-in type that is not explicitly initialized depends on where it is defined. Variables defined outside any function body are initialized to zero. With one exception, which we cover in § 6.1.1 (p. 205), variables of built-in type defined inside a function are uninitialized.