header file confusion
Ok, since my source is big, I want to divide my project into header files like so:
But theres things in player.h that I need in shop.h and monster.h, and when I connect everything to everything all I get is a bunch of errors. Can anyone instruct me on how to properly work header files??
put only declarations and prototypes in header files. if you're already doing that, try this:
do this for all 3 header files. Then, you don't have to worry about things screwing up just because you have included a header file twice.
/* rest of player.h file goes here */
More specifically, the first time any of these header files are included, the #define command is activated. If it's included for the second time or any time after that, #ifndef detects that and just ignores the repeat header file.