Hi there,
I'm writing a simple snake game for a uni course, and I'm having a little trouble linking all the files together
I have 3 classes (Snake, AISnake and GameEvent) and a structure (Positions), Snake and GameEvent share a .hpp and .cpp file and Positions is located in the AISnake .hpp
If I #include AIsnake.hpp in snake.cpp then snake.hpp can't find the position structure
if I #include AIsnake.hpp in snake.hpp then I get an error saying there is not matching function for AISnake::AISnake(), but that function exists
If I #include AIsnake.hpp in both snake.cpp and snake.hpp then the compiler says I'm redefining structure and AIsnake class at the same place its defined in the first place.
I'm assuming that where I want to #include it is in the snake.hpp file, as that is giving me the least errors, and that error also appears when its included in both, which would suggest there's an error somewhere else, but I can't think what that would be, as I do have a function called AISnake::AISnake()
any help would be great.
Cheers
ES
P.S. If you need to see any code just give me a shout, I didn't include any here because I assume you all know what a #include looks like![]()



LinkBack URL
About LinkBacks



