Heya Ben,
You are, of course, totally correct. The only thing we can guarantee is
that 3 will be destroyed first.
Thanks!
Matt
"Ben Hutchings"
Matt S Trentini
wrote: <snip> You'll notice that I left the typedef in there. I can't find anything in the standard (or with google) about it being illegal in main, nor does my compiler emit any warnings. Can anyone shed some light on this?
There's nothing wrong with it. A typedef declaration is allowed wherever any other declaration is allowed, except in the condition of a 'for', 'if', 'switch' or 'while' statement.
And I've got to disagree with your friend about the correct ordering - the expected output is 3, 1, 2 (Remember that foo_ptr gets deleted first).
I don't see any requirement on the order of destruction of sequence elements, so I think it can be either 3, 1, 2 or 3, 2, 1.