[LC++]Scoping question

Jack Lloyd lloyd at acm.jhu.edu
Mon Jul 22 08:57:15 UTC 2002


I've got a question that is just plain nasty, and I've got the feeling I'm
going to have to wade through the ISO spec to figure it out. But I thought
I would take a chance on asking here first.

I have a global variable x.

I also have a static variable y, inside a static member function in a
class.

If x's destructor is called before y's, the program will crash (y needs to
call x to do it's destruction).

Am I guaranteed this will happen as I want by ISO? I know that for global
variables in seperate files, any ordering can be used for their
construction/destruction. Is this the same situation with static variables,
or are they considered to be constructed strictly after and destroyed
strictly before global variables are?

Thanks,
  Jack





More information about the tuxCPProgramming mailing list