在Surface.h我:如何从另一个.cpp文件访问全局结构?
struct Surface{
bool isAllowedOnTile[TILETYPE_COUNT];
float moveBecomes; // When this is 0, it is ignored
float moveChange; // Is ignored if moveBecomes is non-zero
float affChange[ELEMENT_COUNT];
ID2D1BitmapBrush* pBrush;
};
在某个时候,我需要初始化倍数表面是这样的:
Surface surface[SURFACEBMP_COUNT];
surface[0].moveBecomes = 123;
surface[0].moveChange = 0;
surface[0].affChange[0]= 2.0f;
...
然后我想有机会浮出水面[0],表面[ 1],表面[2] ...从我的程序中的任何地方。我怎么做?
显而易见的解决方案是使表面的全局变量(全局数组要准确)。如果没有看到您的代码或理解您的程序设计,这是否是一个好的解决方案很难说。 – john 2013-04-22 11:41:21