This is copy paste from this topic Initializing fields in constructor - initializer list vs constructor body
The author explains the following equivalence:
Your understanding is correct (assuming member1
and member2
have type `int). The two forms are not equivalent; in the
first, the members are not initialized at all, and cannot be
used until they have been assigned. In the second case, the
members will be initialized to 0. The two formulations are only
equivalent if the members are class types with user defined
constructors.