• Advertisement

Archived

This topic is now archived and is closed to further replies.

Header files question

This topic is 5778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I guess I''m just posting this to find out if anyone has a good system of organising their object header files, and how their objects connect to one another through these headers. I''m trying to develope a decent system but keep getting "Missing storage class" errors when I have two objects that need access to each others object type declarations. Does anyone have a system that they swear by, or at least works?

Share this post


Link to post
Share on other sites
Advertisement
Do your classes contains member objects of each other?
Sounds like a circular include to me...one class must contain a pointer to the other, not both member objects

Share this post


Link to post
Share on other sites
*siaspete: Cool - thanks, will look it up

*mageziyx: Yup, but i''ll tell you what it is. For my project, I have a base game object class, and a quad tree class. Now, my game object contains a function which takes a quadtree object in one of it''s member functions, so it can ad itself to it, and also the quadtree class has a templated list, with this game object as it''s data type. Yeah, it is a circular include, but I''m not sure how else to achieve this.

It''s ok anyway - i realise that getting the object to add itself is a bit silly anyway, and have since changed this design slightly. But still, I would like some pointers on how to achieve this, if at all possible.

Thanks again

Share this post


Link to post
Share on other sites
maybe u could dynamically allocate the list with the quadtree only containing a pointer to the list so that there is no need to include the game class in the header for the quadtree.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Use forward declaration and pointers instead of hard object into class.

B.h :
--------

class A;

Class B
{
A* myA;
};


A.h :
------

class B;

class A
{
B* myB;
};


Get it ??

Share this post


Link to post
Share on other sites
Thanks a million guys - a combination of that article and the forward referencing thing worked. I thought I had tried that already, but didn;t realise that you had to remove the header for it aswell.

Cheers again

Share this post


Link to post
Share on other sites

  • Advertisement