vc定义全局变量及extern用法 : 全局变量一般这样定义: 1。在一类的.cpp中定义 int myInt; 然后再在要用到的地方的.cpp里extern int myInt;这样就可以用了。 2。在stdafx.cpp中加入: int myInt; 然后在stdafx.h中加入: extern int myInt 这样定义以后无论在什么文件中都是可见的. 来源:https://www.cnblogs.com/profession/p/12310795.html 标签 extern VC