Hello everyone :) . I am doing a class, which will let me to draw signs to my game screen, to help testing. The main thing is, that I am doing first time it with enumeration, and I get a bunch of not understandable errors. So I hope, that there is anyone, who knows, what I am doing wrong, and could help me :)
error LNK2005: "public: void __thiscall Test_sign::draw(class vector2)" (?draw@Test_sign@@QAEXVvector2@@@Z) already defined in main.obj
error LNK2005: "public: void __thiscall Test_sign::set_color(enum Test_sign::_Color)" (?set_color@Test_sign@@QAEXW4_Color@1@@Z) already defined in main.obj
error LNK2005: "public: __thiscall Test_sign::Test_sign(void)" (??0Test_sign@@QAE@XZ) already defined in main.obj
error LNK2005: "public: void __thiscall Test_sign::draw(class vector2)" (?draw@Test_sign@@QAEXVvector2@@@Z) already defined in main.obj
error LNK2005: "public: void __thiscall Test_sign::set_color(enum Test_sign::_Color)" (?set_color@Test_sign@@QAEXW4_Color@1@@Z) already defined in main.obj
error LNK2005: "public: __thiscall Test_sign::Test_sign(void)" (??0Test_sign@@QAE@XZ) already defined in main.obj
error LNK2005: "public: void __thiscall Test_sign::draw(class vector2)" (?draw@Test_sign@@QAEXVvector2@@@Z) already defined in main.obj
error LNK2005: "public: void __thiscall Test_sign::set_color(enum Test_sign::_Color)" (?set_color@Test_sign@@QAEXW4_Color@1@@Z) already defined in main.obj
error LNK2005: "public: __thiscall Test_sign::Test_sign(void)" (??0Test_sign@@QAE@XZ) already defined in main.obj
fatal error LNK1169: one or more multiply defined symbols found
are defined multiple times. This is because they are included multiple times. Move Test_sign::Test_sign(), void Test_sign::set_color(Test_sign::_Color color) and
void Test_sign::draw(vector2 pos) to a .cpp file. They do not belong in a .h file.
You can keep the definitions inside the header but outside the class if you add the inline keyword to the definitions. Otherwise you violate the One Definition Rule and the linker complains about multiple redefinition.