error C2995: function template has already been defined

The problem is circular dependency. set.h includes set.cpp and set.cpp includes set.h.
Remember that including a file simply pastes its code. There is no need for set.cpp to know about set.h as they will be one file when compiling.
Also, you shouldn’t call set.cpp a cpp file. cpp files are ones that are meant to generate object files. The implementation of a template class must be recompiled for each separate type argument, so it must be in a header and cannot form a separate object. It’s okay to separate implementation from declaration, but do it in a file like set_implementation.h to avoid confusion.

Leave a Comment

tech