Getting "Parent" pointer?

So I have a class World_Object that holds a vector of Component objects. The components send messages to each other. I need a way to send the message (generated in the component inside the World_Object) back up to the World_Object it is located in. I can't create a World_Object pointer in the Component class, as that results in a circular inclusion. Is there a way to throw the message, and automatically have the parent World_Object catch it? (Note Component does not inherit from World_Object, so the World_Object is not actually a base class). I'm trying to figure out if there's a way to do this, or if I've programmed myself into a corner.

The only other idea I had was using a forward declaration, but to my knowledge, both classes would have to be defined in the same file in that case, which doesn't seem like such a good idea.

Thanks in advance.
Last edited on
So I figured out that it works to use the forward declaration of Component in World_Object.h, I was just forgetting to then include Component.h in World_Object.cpp.
That makes sense because the pointer does not need to know the complete type at compile time.
Topic archived. No new replies allowed.