| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||||
|
||||||
|
Class declaration problems
I've been stuck on this error for about a week now and I cant figure out whats going wrong. I have 2 classes that have functions that accept pointers to eachother, and have private variables that point to eachother. One is The map class for a game, and the other is a player class. If i try includeing the class each class is referenceing, i end up with the common problem of one of the classes having to be declared before the other. so to fix this i try to do a class declaration of map in the player file, and player in the map file. then it compiles fine, but when i try to link the object files together, all hell breaks loose.
heres some of the code Player.h Quote:
map_wrap.h Quote:
maintest3.cpp Quote:
output when trying to link Quote:
and on and on for every function call from those classes. please, any help would be nice, was making great progress before hitting this brick wall. |
|
#2
|
||||
|
||||
|
How are you compiling? It seems you are not linking in any of the object files for those classes.
__________________
There is no such thing as C/C++, you either program C or C++ |
|
#3
|
|||
|
|||
|
my make file
makefile
Quote:
|
|
#4
|
|||
|
|||
|
ok
ok, i messed witha few things, have gotten the error messages into a mangable state, and fixed a few problems i was going to have later.
what i have now, is that the functions can communicate with main fine, but can't access functions in eachother. my output now: Quote:
all im doing is #includeing player.h in my map_wrap.cpp file and map_wrap.h in my player.cpp file. do i need to pre-declare all my player functions that i have to use in map_wrap.cpp extern and take out the #includes? (and vice versa for player.cpp) |
|
#5
|
||||
|
||||
|
No you don't need to do that. Including it should work just fine.. It has been a long time since I have written my own make file..
Can you post all the code for player and map_wrap, header and .cpp? Just to check that nothing strange is happening there. Try to do make clean (or better manually delete all object files) before you compile to find out if the makefile is ok. |
|
#6
|
|||
|
|||
|
Here's all my source so far. this fourm doesnt allow links, so have to fudge it.
Quote:
|
|
#7
|
||||
|
||||
|
Ok, I can compile it if I remove all the SDL stuff. I have no time to install sdl and it has been a time since I've used it.
In your makefile your executable was depending on graphics_wrapper.o which does not exist. I really suggest you delete all .o files each time you compile to make sure you're not compiling against old object files. Sorry I can't be more helpful. |
|
#8
|
|||
|
|||
|
no man, thank you so much for just looking. It's linking ok now, but im still trying to figure out why. What i had to do was remove all my inline functions in player.cpp and map_wrap.cpp and it linked up fine.
have any idea why this would fix it? and for the tiny, tiny improvement i would get from inline, is there anyway i can get inline to work? ive tryed both the alias for inline by putting the functions in the .h file, and moveing them to the cpp file with the word inline before the function declaration, but neither fixes the problem im having. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Class declaration problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|