D
Daniel
I think this question will be really easy or really hard to answer.
I have two classes, TestAction and TestObject. Each TestObject has a
pointer to a TestAction, and vice versa. So, both header files need the
#ifndef compiler directives so there will not be an infinite loop of
text substitutions. The problem is, when I use the #ifndef directives,
my code won't compile, and if I take them out, my compiler crashes
because it tries to infinitely include the header files.
Here's the code; it's really simple:
(TestObject.h)
#ifndef TESTOBJECT_H
#define TESTOBJECT_H
#include "TestAction.h"
class TestObject
{
TestAction * tAction;
};
#endif
(TestAction.h)
#ifndef TESTACTION_H
#define TESTACTION_H
#include "TestObject.h"
class TestAction
{
TestObject * tObject;
};
#endif
(TestObject.cpp)
#include "TestObject.h"
(TestAction.cpp)
#include "TestAction.h"
(End)
If it makes a difference, I'm using the beta version of Visual C++
2005. Also, these are just test files to explore the problem -- I
encountered this problem in another project and wrote these test files
as an example of what won't work.
Thanks for the help!
I have two classes, TestAction and TestObject. Each TestObject has a
pointer to a TestAction, and vice versa. So, both header files need the
#ifndef compiler directives so there will not be an infinite loop of
text substitutions. The problem is, when I use the #ifndef directives,
my code won't compile, and if I take them out, my compiler crashes
because it tries to infinitely include the header files.
Here's the code; it's really simple:
(TestObject.h)
#ifndef TESTOBJECT_H
#define TESTOBJECT_H
#include "TestAction.h"
class TestObject
{
TestAction * tAction;
};
#endif
(TestAction.h)
#ifndef TESTACTION_H
#define TESTACTION_H
#include "TestObject.h"
class TestAction
{
TestObject * tObject;
};
#endif
(TestObject.cpp)
#include "TestObject.h"
(TestAction.cpp)
#include "TestAction.h"
(End)
If it makes a difference, I'm using the beta version of Visual C++
2005. Also, these are just test files to explore the problem -- I
encountered this problem in another project and wrote these test files
as an example of what won't work.
Thanks for the help!