Quote:Original post by ajas95
Hmm. It's only guaranteed to be constructed at some point before first-use. So even though you call the constructor, unless you actually /use/ the instance, I don't think you can assume it's constructed.
This is not true. Object construction order is based on the order they appear in the translation unit relative to scope. Whether you use the object or not has no bearing. In the case of multiple translation units, as in this case, you have no guarantee that if one global/static member object uses another one in a separate translation that the second one is initialized first. It's russian roulette whether or not the result is what you'd want. When you first use an object has no bearing on when it is constructed. Again, as I said in my previous post, this is why people often use statics inside functions, since they are constructed the first time the function is called, making construction order (though not destruction order) clearly defined.
Edit: Actually, not in this case, since after reading his source code he's not relying on another object's construction.
[Edited by - Polymorphic OOP on November 8, 2004 6:52:10 PM]