I'm trying to construct two classes that need each other to work but am getting errors when compiling. I need to include settings.h in blocks.h and also to include blocks.h in settings.h
If I don't include blocks.h in settings.h (and remove all objects of type Blocks that are needed) then it compiles perfectly. Same vice versa
I'm using header guards etc, I believe that the problem is because when compiling settings.h, blocks.h needs to be compiled and that needs settings.h to be compiled.
blocks.h:30: error: ‘Settings’ does not name a type
Please help! Is there another way to use a file without including it?
Alas my program is still failing to work but I now have new errors.
I'm forward declaring the classes in each other like so: class Settings;
In another piece of code (main.cpp) I am including both settings.h and blocks.h as I create objects of these types in it.
My error is now: settings.h:138: error: invalid use of incomplete type ‘struct Blocks’
settings.h:6: error: forward declaration of ‘struct Blocks’
This relates to some code in settings.h which attempts to call a function of Blocks
If I switch over the order in which I include the files in main.cpp then my error becomes: blocks.h:221: error: invalid use of incomplete type ‘struct Settings’
blocks.h:6: error: forward declaration of ‘struct Settings’
This relates to code which calls a function of Settings