Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.lang.c++ Subject: Re: Help! Keywords: constructors, C++ i/o, extern Message-ID: <2946@helios.ee.lbl.gov> Date: 6 Jul 89 05:51:53 GMT References: <2774@ssc-vax.UUCP> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 18 The first case works because you are calling a standard C function to do console i/o, which requires no explicit initialization to work. The third case works because all static constructors (which the iostream classes have) are called before you use "cout". The second case doesn't work because of ordering problems in the calling of static constructors. If the stream's constructor was called first, it would work. Anyway, it's really bad practice to write code that depends on the order of calling of static constructors. Don't do it. In fact, I think static constructors are nothing but trouble (mho, of course). I hope this explains your problem. Patrick Beard beard@lbl.gov