On Jul 20, 12:19 am, "JohnQ" <johnqREMOVETHISprogram...@yahoo.com>
wrote:
Quote:
|
"James Kanze" <james.ka...@gmail.comwrote in message
|
Quote:
Quote:
news:1184855301.343186.294920@z24g2000prh.googlegr oups.com...
On Jul 18, 1:59 pm, jubelbrus <thomas.heggel...@gmail.comwrote:
| |
Quote:
Quote: Quote:
I need to initiate a global variable to a class before the
initialization of any other global variable.
| | |
Quote:
Quote:
Why? Check out the singleton idiom. It can't guarantee
this, but it usually guarantees enough---that the variable
is initialized before it is used.
| |
Quote:
The trickier issue is making sure it sticks around long enough
after main because chances are, that if it needs to be used by
other globals before main that it will be used after main
also.
|
In practice, that's less often a problem; destructors generally
don't need nearly as much as constructors. And in the classical
Singleton idiom (in the GoF), the singleton object is never
destructed anyway. (My generic singleton offers the choice, but
defaults to never destructing, since that is the prefered
behavior 99% of the time.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34