这个错误有很多问题。但它们只与一个变量相关。
test.h
namespace World
{
enum Objects
{
TERRAIN = 1,
BOX = 2,
SPHERE = 4,
CAPSULE = 8
};
void WorldObjects2(unsigned int mask)
{
.......
}
}
void test();
test.cpp
#include "test.h"
void test()
{
.......
}
main.cpp
#include "test.h"
int main()
{
test();
return 0;
}
当我在Visual Studio 2013上运行这些代码时,它会抛出一个错误。它说:error LNK2005: "void __cdecl World::WorldObjects2(unsigned int)" (?WorldObjects2@World@@YAXI@Z) already defined in main.obj
。我该如何纠正这个错误?