Path: utzoo!attcan!uunet!nih-csl!lhc!mimsy!brillig.cs.umd.edu!wilson From: wilson@brillig.cs.umd.edu Newsgroups: comp.lang.c++ Subject: Are global class objects special? Message-ID: <26729@mimsy.umd.edu> Date: 26 Sep 90 20:33:45 GMT Sender: news@mimsy.umd.edu Reply-To: wilson@brillig.cs.umd.edu () Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 24 Am I right that there is no way to vary a parameter to a constructor for a class object having global scope without recompilation? I would like to vary the seed to an object which is a random number generator used by several different objects (which is why it is global). Currently the seed must be hard coded since my tests show that the constructor is invoked before main is executed. I am using g++, the GNU C++ compiler. For that matter, is there anything special about having a global class object? I have code which runs properly when class objects are declared within main, but when I move them up above main the code crashes from within the constructor for the first object. Actually the code crashes after trying to free up heap space used for constructing a char* within the constructor. I'm just generally puzzled about execution of code before main in invoked. Apparently, I can't count on all necessary system initializations being performed before my constructors are called. Does anyone have any insights to this issue? Anne Wilson