I have the following files
-
myMainClass.h / myMainClass.cpp
-
myFirstClass.h / myFirstClass.cpp
-
mySecondClass.h / mySecondClass.cpp
myMainClass.h includes the following:
#include <unordered_set>
//private
typedef std::unordered_set<SomeClass, SomeClass_hash> SomeCollection;
SomeCollection m_myCollectionQueue;
// other variables blah blah
myMainClass.cpp includes myFirstClass.h and mySecondClass.h as it uses instances of them. myFirstClass.cpp and mySecondClass.cpp both include myMainClass.h.
When I build I get the following error:
error LNK2005: "class std::unordered_set,class std::allocator > m_myCollectionQueue" (?m_myCollectionQueue@@3V?$unordered_set@SomeClass@@SomeClass_hash@@U?$equal_to@UBackgroundOperation@@@std@@V?$allocator@SomeClass@@@4@@std@@A) already defined in myFirstClass.obj
How can I solve this? I notice that other variables I have declared in myMainClass.h don't force this error only the unordered_set.
