[英]typedef for template class
我有一個模板類,如:
template< type T >
class temp {
T val;
};
我在另一個類中傳遞了這個類對象的引用。
template <type T>
struct def {
typedef def<T> type;
};
class Test {
public:
void func(def<T>::type & obj);
};
我正在嘗試創建一個typedef別名並在函數參數中使用它,但會導致錯誤。 我無法模仿Test類。
您的func
成員函數必須是成員函數模板。 你將不得不增加一個typename
在適當的地方,因為你正在處理一個從屬名稱:
class Test {
public:
template <typename T> // member function template
void func(typename def<T>::type & obj);
// ^^^^^^^^
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.