如何保证一个全局对象第一个构造


定义了一个全局对象,如何保证他是第一个构造呢?我用的是MFC,要保证他保证构造早于theApp

mfc VC

小巫师莫娜 13 years, 2 months ago

全局变量本来就先于theApp构造,可以创建一个MFC工程测试下:

   
  int b=5;
  
CGlableTestApp::CGlableTestApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
int a=0;
if (b==5)
{
int c=0;
}
}

断点设置在"int c=0;"这行,若断到说明全局变量先于theApp构造。

四医院翻墙砖家 answered 13 years, 2 months ago

Your Answer