Original Post
I am writing an upgradable encapsulation of everything. Don''t ask why. I guess I am a bit obsessive, or maybe I have a complex. Who knows?
Well, anyway, I have one class called clsUniverse in clsUniverse.h and .cpp. Another class called clsObject is in clsObject.h and .cpp.
clsObject can be stripped down to this:
class clsObject
{
public:
friend clsUniverse; //I hope this is legal - tell me
private:
bool exists;
clsUniverse* the_universe; //the one that it "exists" in
}
clsUniverse can be stripped down to this:
class clsUniverse
{
public:
void Create (clsObject& an_object);
// an_object.the_universe = this;
}
the clsObject.h file needs to include clsUniverse.h, but clsUniverse.h needs to include clsObject.h. That would mean they would keep including each other infinitely. How do I overcome this problem?
I could do something like this:
clsUniverse.h-
#include "clsObject.h"
clsObject.h-
#ifndef _CLSUNIVERSE_H_
#include "clsUniverse.h"
#endif
Is there any other solution?