c++ - Error [(?testMember@TestClass@@2MA) already defined in TestClass.obj] instead of it's not alrealdy definded ! -


in following class:

class testclass { public:      int staic testmember; };  int testclass::testmember; 

i've got following compiler error:

error lnk2005: "public: static float testclass::testmember" (?testmember@testclass@@2ma) defined in testclass.obj

note: i've tried simulate problem in seperated application worked there.

i wonder problem here?

your definition:

int testclass::testmember; 

...is in same h file declaration:

class testclass { public:      int staic testmember; }; 

move definition it's own cpp file. need define once.


Comments