Header files question

Started by
5 comments, last by Terren 21 years, 9 months ago
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?
Advertisement
I believe there''s an article about this very thing right here.

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
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
*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
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.
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 ??
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

This topic is closed to new replies.

Advertisement