I need to use a struct defined in A.h as both a parameter to a method as well as a data element to another struct in B.h. (I can't use a pointer to StructA in StructB because the data to which it would point eventually changes, and I need to preserve the original data in a local copy in StructB.)
A.h:
struct StructA {
...
}
B.h
#include "A.h"
struct StructA;
class B {
method foo (StructA &structA);
struct StructB {
...
StructA structA
}
By including A.h in B.h, isn't the declaration of StructA available in B.h? However, the compiler complains that "field structA has incomplete type".
If I don't forward declare StructA, the compiler then complains StructA is not declared in method foo. So, obviously the declaration isn't available in B.h.
I'm missing something fundamental here, but I can't figure it out and it's driving me insane! Please help!