![](/img/trans.png)
[英]How to specialize a templated member-function into a templated class in C++?
[英]C++ - how to implement templated member function outside a templated class
template<int N>
class myClass
{
template<typename T>
void myFunction();
};
template<typename T>
void myClass<int N>::myFunction() {} // doesn't work, nor do many other combinations!
嗨,
是否有可能實現上述目標? 我可以在類定義中實現myFunction沒問題。 如果是這樣,語法是什么? GCC 4.2告訴我:
缺少'>'來終止模板參數列表
謝謝你的幫助
您正在尋找:
template <int N>
template <typename T>
void myClass<N>::myFunction() {}
您需要一個template
用於類模板,一個模板用於成員函數模板。
template<int N> template<typename T>
void myClass<N>::myFunction() {}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.