c++ template函數的聲明和實現須要在同一個文件中

新建一個class C;生成2個文件C.h和C.cpp,在C.h中聲明一個函數函數

template<class T>編譯器

T stringTo(char* str);string

直接用VAssistX的Refactor-Create Implementation菜單,發現沒有在C.cpp實現stringTo函數,而是在C.h中生成io

template<class T>編譯

T C<T>::stringTo(char* str)class

{文件

}生成

 

網上說template修飾的函數,目前的編譯器對於分開聲明和實現的狀況支持不是很好。。

相關文章
相關標籤/搜索