Question: How would I go about doing something like this?

header.h

```
 struct myStruct;
 extern myStruct array[];

```

main.cpp

```
#include "header.h"
struct myStruct{
int a = 0;
};
myStruct array[5];
array[0].a = 1;

```

file2.cpp

```
#include "header.h"
std::cout << array[0].a;

```

Answer: 
The size and layout of `myStruct` needs to be known everythere you try to access its contents, so you must either define it inside of the .h file, or only access it using opaque pointers and dedicated functions.

Also, using C arrays in C++ is somewhat outdated. You should use STL containers instead, such as `std::array<T, N>` or `std::vector<T>`.
> 
> How would I go about doing something like this?
> 
> 
> 

You could go about doing something like what you did by doing something like what you did, except fixing the bugs in your attempt. Here is the list of bugs:

* You failed to end the definition of `myStruct` with a semicolon.
* `.c` suffix is conventionally for C source files while you're writing C++. Your compiler will likely be confused unless you provide some unconventional options to the compiler.
* You use `cout` which you forgot to declare. Or did you intend to use `std::cout`? In that case you must include `<iostream>` in order to use it, and use the appropriate namespace.
* In `file2.c`, you use the class `myStruct` in a way that depends on the definition of `myStruct` without providing that definition.
* `array[0].a = 1;` and `cout << array[0].a;` are expression statements. Expression statements may not be in namespace scope, and must be within a block scope. In your program, those expression statements are in the namespace scope which makes the program ill-formed.