Archived

This topic is now archived and is closed to further replies.

PsYcHoPrOg

VC++ loves me so.

Recommended Posts

I''m working on a mini-project to test out the sprite engine that I just recently threw together. The project compiles with no errors, but won''t build without giving me an error for every member function in all classes associated with the project. Each error looks somewhat like this: MainTest.obj : error LNK2005: "public: void __thiscall Sprite::ChangeLoc(int,int)" (?ChangeLoc@Sprite@@QAEXHH@Z) already defined in EngineTest.obj I can''t help but feel that this is all due to a simple precaution that I didn''t bother to take, or that I just made some really stupid mistake. Anyway, any suggestions would be appreciated. _.-|PsYcHoProg|-._

Share this post


Link to post
Share on other sites
Looks like you''re linking in your library _and_ including the source for the library in the project? You should only include the necessary header files for your library, not the source files (that''s kinda the point of libraries).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
you are including your headers multiple times. If A.h includes B.h and C.cpp includes both it will have two copies of everything in A.h and that is bad. So what you want to do is put something like this at the top of every header:

#if !defined(MyClass_header)
#define MyClass_header

and then at the bottom put:

#endif

Share this post


Link to post
Share on other sites