我有一个VC++解决方案(使用VS2008),有两个项目A & amp;项目B。
下面我讨论的一切都是A项目
Project A has a sourec file a.cpp & it includes a header file "a.h". "a.h" has a variable int varA; which is modifies inside a.cpp.
a.cpp:
int varA = x*2;
// also do some calculations with varA in a.cpp
Now there is one more sourec file b.cpp in the same project A. And now lets say this "b.cpp" also includes same header file "a.h". i.e
b.cpp
int varB = varA; // If I want to access varA & get the current value of varA here in b.cpp what should do ? Will it work if I declare varA as extern in a.h & include
这里必须注意的是,我不仅要从 b. cpp 内部访问变量 varA, 还要访问 a. cpp. genery > 更新的该变量的当前值
提前订货