Order of constructor/destructor invocation
Björn Lindberg
d95-bli.no at spam.nada.kth.se
Thu Mar 7 09:09:42 EST 2002
Christian Tanzer wrote:
> Before this thread I would have agreed that destruction order is
> completely well defined. Looking at your example I'm not sure about
> one case. What if you write:
>
> void a_function ()
> {
> sentry1 s1, s2;
> ...
> }
>
> ? Will s1 be destructed before s2 by all compilers? Guess, I never
> cared about that because I tend to use multiple declarations myself.
The destruction order is always opposite of the construction order. In
this example s1 will be constructed first followed by s2. Destruction is
performed in the opposite order, so s2 will be destructed first followed
by s1.
Björn
More information about the Python-list
mailing list