quote:Original post by paulsdsrubbish
You cannot accurately predict what order static object instances will construct and destruct.
Within a single translation unit (single cpp file + everything you #include), objects are initalized in the order in which they are defined. Destructors run in reverse order (see my previous post).
Across multiple translation units, the order of initialization is undefined. That is, you cannot control whether the objects defined in foo.cpp will be constructed before or after those in bar.cpp
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan (C programming language co-inventor)