C++: Construction and initialization order guarantees

前端 未结 5 438
南笙
南笙 2020-12-03 11:14

I have some doubts about construction and initialization order guarantees in C++. For instance, the following code has four classes X, Y, Z

5条回答
  •  抹茶落季
    2020-12-03 12:01

    1. The W object will be constructed before the constructor to X is called.
    2. Z, as a base class of X, will be initialized before the members of X.
    3. Y will be initalized during member initialization
    4. X's constructor will run.

提交回复
热议问题