I got this error, which I don’t get at all. I interpreted it to be that I have something that’s defined differently more than once, but when I look through my code, I just don’t see it. I uploaded the codes that the error message has pointed to:
teamdata.obj:-1: error: LNK2005: "public: int __thiscall teamdata::getTeamnumber(void)" (?getTeamnumber@teamdata@@QAEHXZ) already defined in scouting.obj
teamdata.obj:-1: error: LNK2005: "public: bool __thiscall teamdata::operator<(class teamdata)" (??Mteamdata@@QAE_NV0@@Z) already defined in scouting.obj
release\Scouting.exe:-1: error: LNK1169: one or more multiply defined symbols found
Links:
teamdata.h http://pastebin.com/5u0YzK84
teamdata.cpp http://pastebin.com/GP0zRzpw
Just as the linker is telling you, your functions
getTeamnumber()andoperator <are defined in two different translation units: inscouting.cpp(I guess that’s the name of the file) and inteamdata.cpp.It does not matter whether the definitions are identical or different (function templates are an exception to this rule, but that’s not your case, as your functions are not tmeplates), as long as they are multiple.
The One Definition Rule (Clause 3 of the C++ Standard) states that each entity of your program shall only have one definition.