I'm trying to do something like this:
MainClass.h:
SecondaryClass.h:Code:#ifndef __MAIN_CLASS_H
#define __MAIN_CLASS_H
#include "SecondaryClass.h"
class MainClass
{
private:
SecondaryClass *secondaryClass;
public:
MainClass();
~MainClass();
};
#endif
And I get the following errors:Code:#ifndef __SECONDARY_CLASS_H
#define __SECONDARY_CLASS_H
#include "MainClass.h"
class SecondaryClass
{
private:
MainClass *m_mainClass;
public:
SecondaryClass( MainClass* );
~SecondaryClass();
};
#endif
I'm sure this is because I am including a file that includes the file I'm currently in.Quote:
In file included from MainClass.h:4,
from main.cpp:2:
SecondaryClass.h:9: error: ISO C++ forbids declaration of `MainClass' with no type
SecondaryClass.h:9: error: expected `;' before '*' token
make.exe: *** [main.o] Error 1
The point of this being that MainClass has a member variable of Secondary class, which also has a reference to the MainClass that instantiated it.
Any ideas on how to accomplish this?
