Having read many links about setting up templates on classes I have got to this perplexing compiler error:
Linking...
main.obj : error LNK2019: unresolved external symbol "public: __thiscall test<int,int>::test<int,int>(int)" (??0?$test@HH@@QAE@H@Z) referenced in function _main
fatal error LNK1120: 1 unresolved externals
The offending code, as simply as possible is:
test.h
template<typename U, typename V>
class test {
public:
test(int number);
};
test.cpp
#include "test.h"
template<typename T, typename U>
test<T, U>::test(int number){}
main.cpp
#include "test.h"
void main() {
test<int, int> a = test<int, int>(4);
}
Clearly the previous code does nothing useful, I am simply building a model of templates to start a project. Can anyone explain what I'm not understanding about structuring this solution to meet the ends of having a templated class that can construct itself correctly?