|
-
March 8th, 2008, 02:11 AM
#3
Re: I'm getting Linking errors about functions already being defined in other .obj fi
 Originally Posted by Mybowlcut
I think you'll eventually want to put the enums that are relevant to Move, Piece and Player in their respective header files.
Do you mean that if both Piece and Player need this enum:
Code:
enum Type { PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING, NO_TYPE };
...that I should actually have it written twice? One in each of their respective header files? I guess that makes sense. I just assumed that would be bad form to have something written twice when it could only have to be written once. But I can see how this would help like you said. The only downside is that if I decide to alter 'Type', I have to now remember to update BOTH locations rather than just the one.
 Originally Posted by Mybowlcut
As for your problem.. are you sure all your include guards are correct? Names are spelt correctly, etc.? ...are you sure you've got semi-colons at the end of your class declarations?
I double checked all the syntax and I believe it's up to snuff. I was thinking it might have something to do with one of these two reasons:
1) The placement of the #include directives. I always place any #include directives after the inclusion guards (#ifndef/#define...) and of course before the #endif. Could it ever be necessary to #include a file before the inclusion guard?
2) I read somewhere that anything in the header file is public and anything in the implementation file is private. Could that have something to do with the errors? I have no clue.
My solutions: 1) Just don't define any functions in my header file, declarations only, or 2) move everything from the implementation file over to the header file and just get rid of Display.cpp altogether. I've tried both solutions and they both work. I was just trying to figure out why I was getting those darned errors. Oh well, something for another day I suppose...
Thanks again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|