Possible Duplicate:
Why can templates only be implemented in the header file?
I have written template method in non-template class. This project is static library.
Then I have written test console application and wanted to use this method. But there is compilation error (unresolved external). Then I asked google and have found forum (http://cboard.cprogramming.com/cplusplus-programming/108544-static-libraries-template-functions.html) where ‘matsp’ said: “The entire template implementation needs to be in a header file when using templates.”. I did like he said and it works great. Why?
Because that’s the way it is with templates in C++… Their definition has to be visible in every translation unit that is used.