Welp, fell on my face. This one is kinda hard to explain.
I have stage class and I have various stage object classes (like hector and pipes). I need to pass an instance of stage to these stage objects but it requires that stage.h be included in these stage objects header files BUT stage.h needs to include these stage object headers in order to declare lists of them.
#ifndef GYROPIPE_H //Standard include guards
#define GYROPIPE_H
//Only #include stage.h if you really need to
class Stage; //class prototype
class GyroPipe {
GyroPipe(Stage* stageInstance...)
};
#endif
We must've posted at the same time :) Include guards prevent a file from being pasted into your project more than once by the compiler (causing compilation errors)
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
That's true, but there's no saying you can't use #define... I wasn't saying #define was the only way to do so, or even the best. It's just that those are really the only two reasons to use them these days, seeing as macros aren't as good as inline functions
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Well, if you have the guards, there shouldn't be any problem. You might not understand how the compiler manages to make it work, but the compiler does.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Ginto8 wrote:Well, if you have the guards, there shouldn't be any problem. You might not understand how the compiler manages to make it work, but the compiler does.
.... no. It doesn't. The way I had it didn't work. The files relied on each other in an impossible kind of way. Class prototyping fixed that.
Small girl at the harbor wrote:Look Brandon, that crab's got ham!