全局变量一般这样定义:
方法一、在一类的.cpp中定义 int myInt;
然后再在要用到的地方的.cpp里extern int myInt;这样就可以用了。
方法二、在stdafx.h中加入:
extern int myInt;//这里的分号不要漏
在stdafx.cpp中加入:
int myInt;
这样你就可以在所有包含#include "stdafx.h"文件中均可以使用myInt变量了。
参考资料:
http://blog.sina.com.cn/s/blog_6d12a6950100mr8s.html