Typedef with template parameter in C++ [duplicate]
问题 This question already has an answer here : C++ template typedef (1 answer) Closed 6 years ago . How can I solve this error? My header file template<typename T> class C1 { public: typedef std::vector<T::F> TFV; TFV Function1(); }; My CPP file template<typename T> TFV C1::Function() //error: ‘TFV’ does not name a type { } 回答1: First of all, use the typename keyword to tell the compiler to interpret F as the (qualified) name of a type: typedef std::vector<typename T::F> TFV; // ^^^^^^^^ Secondly