我有類模板方法:模板法實施<>
template<class T>
A& doSomething(T value)
然後,我有一個實現
template<class T>
A& A::doSomething(T value){
// do something with value
return *this;
}
然後,我有一個專門用於讓說布爾
template<>
A& A::doSomething(bool value){
// do something special with value of type bool
return *this
}
這是我明白,現在在代碼中有這樣的東西,我不知道什麼意思:
template A& A::doSomething(char const*);
template A& A::doSomething(char);
template A& A::doSomething(int);
template A& A::doSomething(int*);
template A& A::doSomething(double);
...
這些最後5行模板的確切含義是什麼?
謝謝
沒有標準'extern'模板C++ 03 – Garf365
@ Garf365添加到答案。 – songyuanyao
謝謝,現在我明白了。我認爲這個用例是爲了避免在鏈接到在cpp文件中實現其模板的庫時的未定義引用。我對嗎? – Jan