Extern Struct in C++?
You put the struct MyStruct
type declaration in a .h
file and include it in both class1.cpp and class2.cpp.
IOW:
Myst.h
struct MyStruct {
int x;
};
Class1.cpp
#include "Myst.h"
MyStruct theVar;
Class2.cpp
#include "Myst.h"
extern struct MyStruct theVar;
void test() {
int t = theVar.x;
}