Re: 'static initialization' vs. 'dynamic initialization'
s5n wrote:
On Feb 16, 2:57 pm, "James Kanze" <james.ka...@gmail.com> wrote:
Order of initialization can be a serious problem, however, and
one of the main reasons I sometimes use C style arrays instead
of std::vector is precisely to obtain static initialization, and
avoid order of initialization problems. (Similarly, I'll use a
presorted C style array and std::lower_bound rather than
std::map or std::set for constant objects with static lifetime,
in order to avoid order of initialization problems.)
That's an interesting idea, but in some exotic cases you still have
potential destruction ordering problems.
Such as? If I'm using PODs, there is no destruction. For that
matter, when using the singleton pattern, I normally don't
destruct the objects. It's not necessary, and it is dangerous.
--
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
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]