On Wed, 2007-12-26 at 21:03 -0700, Thomas Hruska wrote: > Tamas Marki wrote: > > On 12/26/07, Michael Sullivan <[EMAIL PROTECTED]> wrote: > >> In my project I have moved the majority of SDL code from the Battle > >> class to a new class called DrawBattle. I'm trying to build it, but > >> DrawBattle refuses to recognize my Battle class. I know that this > isn't > >> finished, but I prefer to debug and rebuild as I go. I have pasted > the > >> code for only the relevant classes: > > > > [snip code] > > > > I didn't really read through all your code, but it seems like that > you > > are falling into the 'recursive includes' trap, meaning that > battle.h > > includes drawbattle.h and vice versa. Just think about it for a > moment > > what would you do if you were the preprocessor... Confused yet? :) > > You might need to rethink that part a bit. > > HTH > > He does have the #ifdef/#ifndef's in place. If there were a recursive > problem, the compiler would have died there. > > Michael, try this: > > Remove the 'drawbattle.h' #include from 'battle.h'. Then, before your > declaration of Battle, do: > > class DrawBattle; > > That tells the compiler that somewhere else is going to be a full > class > definition of DrawBattle. This is the usual approach to dealing with > circular references. > > -- > Thomas Hruska > CubicleSoft President > Ph: 517-803-4197 > > *NEW* MyTaskFocus 1.1 > Get on task. Stay on task. > > http://www.CubicleSoft.com/MyTaskFocus/
OK. The definitions for both Battle and DrawBattle are in battle.h, with the above mentioned addition above the Battle class. My errors are still the same: g++ `sdl-config --cflags` -I/usr/local/include/mysql++/ -I/usr/include/mysql -L/usr/local/lib -c battle.cpp drawbattle.h:10: error: expected `)' before '*' token drawbattle.h:32: error: ISO C++ forbids declaration of 'Battle' with no type drawbattle.h:32: error: expected ';' before '*' token battle.h:30: error: redefinition of 'class DrawBattle' drawbattle.h:7: error: previous definition of 'class DrawBattle' battle.cpp: In member function 'bool Battle::initialize()': battle.cpp:30: error: no matching function for call to 'DrawBattle::DrawBattle(Battle* const)' drawbattle.h:9: note: candidates are: DrawBattle::DrawBattle() drawbattle.h:7: note: DrawBattle::DrawBattle(const DrawBattle&) make: *** [battle.o] Error 1 If you need me to repost my code, please ask...
