C++: Construction and initialization order guarantees

前端 未结 5 448
南笙
南笙 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 11:53

    To summarize these are the rules:

    1. Arguments, taken from Right to Left
      a. Right Most
      b. 2nd from Right
    2. Base class
    3. Virtual base
    4. Base classes from Left to Right
    5. Members in Order of Declaration in class
    6. Constructor of called class

提交回复
热议问题