I have something similar to the following:
header1.h
#include "header2.h"
struct MyStruct
{
int aVariable;
};
class AClass
{
AnotherClass m_anotherClass;
}
header2.h
class AnotherClass
{
AnotherClass(MyStruct & myStruct)
: m_myStruct(myStruct)
{
}
MyStruct & m_myStruct;
};
I was wondering how I can get access to MyStruct in header2.h when I have defined it in header1.h. I know I could just move definition of the struct into header2.h but it wouldn't really make sense for it was meant for.
The only reason I wanted to do it this way was because I wanted to be able to get to the data stored in aVariable that gets updated in header1.cpp.