1.方案
在StdAfx.cpp中定义,如int g_nMyGlobal=0,在StdAfx.h中extern int g_nMyGlobal。
2.方案
放到theApp的类中,作为theApp的成员变量,调用的时候(CMyApp*)AfxGetApp()->m_nMyGlobal。
3.方案
写一个类
class MyGlobalData
{
public:
static int gd_nMon;
static int gd_nDay;
};
int MyGlobalData::gd_nMon = 0;
int MyGlobalData::gd_nDay = 0;
这样调用:
//...
int x = MyGlobalData::gd_nMon;
int y = MyGlobalData::gd_nDay;
//...