如果想在别的文件里调用不在声明类某个函数或者变量,可以使用extern
比如在A.h 声明extern bool g_AppShowStatsLabel;
extern string GBKTOUTF8(const char *inbuf);这两个声明都不在类里面声明,都在类外声明的。
在B.cpp调用g_AppShowStatsLabel = true; GBKTOUTF8("调用");
总结就是加上extern在某个文件类外声明,其他文件都可以调用它。
如果想在别的文件里调用不在声明类某个函数或者变量,可以使用extern
比如在A.h 声明extern bool g_AppShowStatsLabel;
extern string GBKTOUTF8(const char *inbuf);这两个声明都不在类里面声明,都在类外声明的。
在B.cpp调用g_AppShowStatsLabel = true; GBKTOUTF8("调用");
总结就是加上extern在某个文件类外声明,其他文件都可以调用它。