[EC++_item4]确定对象被使用前已先被初始化
2014-04-08 21:42
197 查看
Things to Rember:
1.Manually initialize objects of built-in type, because C++ only sometimes initializes them itself.
为内置型对象进行手工初始化,因为C++不保证初始化它们。
2.In a constructor, prefer use of the member initialization list to assignment inside the body of
the constructor. List data members in the initialization list in the same order they're declared in
the class.
构造函数最好使用成员初值列(member initialization list),而不要在构造函数本体内使用赋值操作(assignment)。
初值列列出的成员变量,其排列次序应该和它们在class中的声明次序相同。
3.Avoid initialization order problems across translation units by replacing non-local static objects with local static
objects.
为免除“跨编译单元之初始化次序”问题,请以local static对象替换non-local static对象。
1.Manually initialize objects of built-in type, because C++ only sometimes initializes them itself.
为内置型对象进行手工初始化,因为C++不保证初始化它们。
2.In a constructor, prefer use of the member initialization list to assignment inside the body of
the constructor. List data members in the initialization list in the same order they're declared in
the class.
构造函数最好使用成员初值列(member initialization list),而不要在构造函数本体内使用赋值操作(assignment)。
初值列列出的成员变量,其排列次序应该和它们在class中的声明次序相同。
3.Avoid initialization order problems across translation units by replacing non-local static objects with local static
objects.
为免除“跨编译单元之初始化次序”问题,请以local static对象替换non-local static对象。
相关文章推荐
- Effective C++ Item 4 确定对象被使用前已先被初始化
- Effective C++ Item 04-确定对象被使用前以先被初始化
- Item 04:确定对象被使用前已先被初始化
- 重读经典-《Effective C++》Item4:确定对象被使用前已先被初始化
- Item 4:确定对象被使用前已先被初始化【effective C++读书笔记】
- Effective C++ 之 Item 4:确定对象被使用前已先被初始化
- Item 4 :确定对象使用前已经被初始化
- Effective C++ Item 4 确定对象被使用前已先被初始化
- 条款4:确定对象被使用前已经被初始化
- effective c++条款04确定对象使用前已经被初始化
- 条款04:确定对象被使用前已经先被初始化
- 《Effective C++》Item4:确定对象被使用前已先被初始化
- [Effective C++]条款04 确定对象被使用前已先被初始化
- effective C++ 04_确定对象被使用前已被初始化 读书笔记
- 确定对象被使用前巳先被初始化
- 条款04 确定对象使用前已被初始化
- Effective C++学习笔记 条款04:确定对象被使用前已先被初始化
- 【Effective C++ 读书笔记】条款04:确定对象使用前已先被初始化
- 条款04:确定对象被使用前已先被初始化
- Effective C++学记之04 确定对象被使用前先被初始化