可能重複:
Why can templates only be implemented in the header file?模板方法在C++靜態庫
我已經寫在非模板類的模板方法。這個項目是靜態庫。 然後我寫了測試控制檯應用程序,並想使用這種方法。但有編譯錯誤(無法解析的外部)。然後,我問谷歌,並找到論壇(http://cboard.cprogramming.com/cplusplus-programming/108544-static-libraries-template-functions.html)'matsp'說:「使用模板時,整個模板實現需要在一個頭文件。」我確實喜歡他說的,而且效果很好。爲什麼?
看看[這裏](http://stackoverflow.com/questions/5612791/c-template-and-header-files) –