1.你所寫的 template 內容要在這個地方才會被 complier
2.在 testa.cc 之中,你沒有把 a.cc include 進來,所以在 compiler 的
時候 contructor 並沒有被處理,所以在 link 的時候變成 undefined symbol
3.把 template 的成員函數獨立成一個檔案是沒有必要的,記得 1. 中所說
4.如果一定要這樣作的話,記得在 a.h(或 testa.cc) 中加上
#include <a.cc>
在 C++ Primer(3rd edition) 書中提到, template 不支援 separation compilation
model, 必須加 export 才可
但似乎 g++ 2.8.1 還沒支援 export
--
* Origin: ★ 交通大學資訊科學系 BBS ★ <bbs.cis.nctu.edu.tw: 140.113.23.3>