The initialization steps are given in 3.6.2 "Initialization of non-local objects" of the C++ standard:
Step 1: x
and y
are zero-initialized before any other initialization takes place.
Step 2: x
or y
is dynamically initialized - which one is unspecified by the standard. That variable will get the value 1
since the other variable will have been zero-initialized.
Step 3: the other variable will be dynamically initialized, getting the value 2
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…