Possible Duplicate:
When to use forward declaration?
C++ classes with members referencing each other
I am pretty new to C++, and I have a question regarding two structures defined below as shown below. Each struct contains a pointer to the other:
struct A{
...
...
B *ptr;
}
struct B{
...
...
A* ptr;
};
However, since the 2nd structure is defined only after the first, I get a compilation error. Is there a solution for this? I tried to declare the struct separately in header files, but it didn't work. Any help is appreciated! Thanks.