¿Cómo tener acceso a la estructura global desde otro archivo .cpp? [duplicar]
Esta pregunta ya tiene una respuesta aquí:
Usando una clase / estructura / unión sobre múltiples archivos cpp C ++ 5 respuestasen Surface.h tengo:
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;
};
En algún momento, necesito inicializar la superficie de múltiplos de esta manera:
Surface surface[SURFACEBMP_COUNT];
surface[0].moveBecomes = 123;
surface[0].moveChange = 0;
surface[0].affChange[0]= 2.0f;
...
Luego quiero tener acceso a la superficie [0], la superficie [1], la superficie [2] ... desde cualquier lugar en mi programa. ¿Cómo puedo hacer eso?