//////////////////////////// // global.h // extern int g_iParam; // declare the parameter//------------------------------end of the file//////////////////////////// // global.cpp //int g_iParam = 0; // define the parameter//-----------------------------end of the file //////////////////////////////// // CMyDialog.cpp //#include "CMyDialog.h" #include "global.h" // ... other codesextern int g_iParam; // declare the parametervoid CMyDialog::OnMessage() { g_iParam = 1; // access the parameter. }...//-------------------------------- end of this file
CMyDialog.cpp文件中下面这一行可以不用了,因为有了#include "global.h":extern int g_iParam; // declare the parameter
其它同意jimconrad(jimmy)。
// global.h
// extern int g_iParam; // declare the parameter//------------------------------end of the file////////////////////////////
// global.cpp
//int g_iParam = 0; // define the parameter//-----------------------------end of the file
////////////////////////////////
// CMyDialog.cpp
//#include "CMyDialog.h"
#include "global.h"
// ... other codesextern int g_iParam; // declare the parametervoid CMyDialog::OnMessage()
{
g_iParam = 1; // access the parameter.
}...//-------------------------------- end of this file