There is a difference between defining something and declaring an instance of something:
Code:
struct somestruct // Defines a struct called "somestruct"
{
float x, y;
};
somestruct foo; // Declares an instance of a somestruct struct
If you have a multifile project (which it seems you do), you could not declare an instance of an object in the header file and then include the header file in all of the source files because the linker would complain about the same variable name existing in multiple places. So I will assume you have just defined the struct in the header (which is perfectly OK to include in multiple source files) and that the instance of the struct you are attempting to read the values from in one source file exists in another source file as in:
header.h
Code:
struct foo
{
float x, y;
};
source1.cpp:
Code:
#include "header.h"
foo myfoo; // Declared an instance of struct foo called myfoo.
Now, if you want to access the values of myfoo in this second source file you need to use the extern keyword as such.
source2.cpp:
Code:
#include "header.h"
extern foo myfoo; // Says there is a foo struct called myfoo in another source
// file somwhere that we'd like to access the contents of in
// this source file
...
void somefunc()
{
float somefloatx = myfoo.x; // Access myfoo's x member value
float somefloaty = myfoo.y; // Access myfoo's y member value
}