读《Effective C++第三版》笔记Item4

来源:互联网 发布:湖南大学软件培训中心 编辑:程序博客网 时间:2024/06/06 14:13

1.初始化的顺序

在一个类的对象中引用另外一个类的对象时应该保证引用的对象已经初始化了。如果不进行初始化the relative order of initialization of non-local static objects defined in a different translation units is undefined. Replace direct access to the non-local static object with calls functions that return reference to the local static object, you are guaranteed the reference you get back will reference the initialized objects.

0 0
原创粉丝点击