所以我有以下代碼:如何使用C++中的typedef函數指針必須返回類模板?
typedef Shape *(createShapeFunction)(void);
的問題是,形狀是一個模板,所以我想它是這樣的:
typedef Shape<T> *(createShapeFunction)(void);
我已經嘗試以下
typedef template<typename T> Shape<T> *(createShapeFunction)(void);
template<typename T> typedef Shape<T> *(createShapeFunction)(void);
它給了我錯誤,說這是不允許的。 你能幫忙嗎?
in C++ 11'using'應該用來代替'typedef' –
@BryanChen我會用它,但我很沮喪地使用新標準,所以我想嘗試不太現代的方法 – ciprianr
@ciprianr:不要讓他們勸阻你。 C++ 11非常棒! – Danvil