The following code does not compile in VS 2010 Visual C++.
I get the error:
error LNK2019: unresolved external symbol "public: __thiscall testTemplate<double>::testTemplate<double>(void)" (??0?$testTemplate@N@@QAE@XZ) referenced in function _main main.obj
But if I move the code between
// Begin Comment
and
// End Comment
into the file main.cpp, the code compiles.
I am not sure why the compiler is complaining about the testTemplate class but not about the test class.
You should never place template definitions within a source module as it causes URES errors. Make sure that template definitions are within the same file as the class/function declaration. You can also in-line template definitions by placing them (definitions) within a file (.inl) and #include it beneath the class/function.
Actually responding to your error would help wouldn't it? :)P
By looking at your error, it seems as though the compiler invoked the default constructor of testTemplate. However, the linker cannot find the definition of testTemplate< T >::testTemplate( ). In order to fix this, you must do what I said before (above).