码迷,mamicode.com
首页 > 其他好文 > 详细

类的编译顺序

时间:2021-06-02 19:16:37      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:title   cto   derived   nal   line   ber   rsa   actual   rect   

Initialization order

The order of member initializers in the list is irrelevant: the actual order of initialization is as follows:

1) If the constructor is for the most-derived class, virtual bases are initialized in the order in which they appear in depth-first left-to-right traversal of the base class declarations (left-to-right refers to the appearance in base-specifier lists)
2) Then, direct bases are initialized in left-to-right order as they appear in this class‘s base-specifier list
3) Then, non-static data member are initialized in order of declaration in the class definition.
4) Finally, the body of the constructor is executed

(Note: if initialization order was controlled by the appearance in the member initializer lists of different constructors, then the destructor wouldn‘t be able to ensure that the order of destruction is the reverse of the order of construction)

类的编译顺序

标签:title   cto   derived   nal   line   ber   rsa   actual   rect   

原文地址:https://www.cnblogs.com/wildricky/p/14833229.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!