Data member declarations may include variable initializers. For shared data members, variable initializers correspond to assignment statements that are executed after the program begins executing but before the shared data member is first referenced. For instance data members, variable initializers correspond to assignment statements that are executed when an instance of the class is created.
All data members are initialized to their default values, including data members that have variable initializers. Thus, when a program begins executing, all shared data members are first initialized to their default values before any shared data member initializers are executed. Likewise, when an instance of a class is created, all instance data members are first initialized to their default values, and then the instance data member initializers are executed. Each variable initializer must yield a value of the data member's type or of a type that is implicitly convertible to the data member's type. The variable initializer may be circular, even though such an initializer is of dubious value.
There are four forms of variable initializers: regular initializers, array element initializers, array size initializers and object initalizers. The first two forms appear after an equals sign that follows the type name, the latter two are part of the declaration itself. Only one form of initializer may be used on any particular declaration, with the exception that an array size initializer and an array element initializer may be used together.