MFC中全局变量的定义及使用
一、在应用程序类中定义
需继承 CWinApp 类;
CTestApp *app = (CTestApp *)AfxGetApp(); //生成指向应用程序类的指针
二、用静态变量和静态函数实现
public:
static int x; //全局变量
static int time; //全局变量
static int f(int y); //全局函数
int CPublic::x = 0; //初始化全局变量
int CPublic::time; //定义全局变量
转载自: