ordering of constructors
Daniel Jacobowitz
drow@false.org
Fri Apr 9 14:25:00 GMT 2004
On Fri, Apr 09, 2004 at 02:15:24PM +0200, Gabriel Dos Reis wrote:
> For example, it can be something like
>
> A.H:
> struct A { some constructor ... };
> extern A a;
> void make_sure_a_is_constructed();
>
> A.C
> A a;
>
> void make_sure_a_is_constructed() { /* empty */ }
>
>
>
> B.H:
> #include "A.H"
> struct B { ... }
>
> B::B()
> {
> make_sure_a_is_constructed();
> // use a...
> }
>
> B.cc;
> B b;
>
>
>
> The call to make_sure_a_is_constructed(), will provoke the
> initialization of a, before that function is executed.
Er... for those of us ignorant, could you explain why this assures
anything?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
More information about the Gcc
mailing list