In C++, object construction and destruction can involve executing user code. Therefore, it is important to understand which initializations happen before entry to main, and which destructors are invoked after exit from main. (For detailed information about construction and destruction of objects, see “Constructors” and “Destructors” in Chapter 11, on topic and topic, respectively.)
The following initializations take place prior to entry to main:
Default initialization of static data to zero. All static data without explicit initializers are set to zero prior to executing any other code, including run-time initialization. Static data members must still be explicitly defined.
Initialization of global static objects in a translation unit. This may occur either before entry to main or before the first use of any function or object in the object's translation unit.
Microsoft Specific
In Microsoft C/C++, global static objects are initialized before entry to main.¨
Global static objects that are mutually interdependent but in different translation units may cause incorrect behavior.