c++ - Cannot pass template argument to std::list<T>::iterator -
this question has answer here:
i made container template class follow:
template<typename k, typename v> class hash_table { public: class iterator { private: list<v> list_; // works list<v>::iterator it_; // fails: syntax-error "iterator" list<int>::iterator it2_; // works }; //.... } can tell me, did wrong @ list<v>::iterator it_;? why should syntax error?
as @songyuanyao sugested, solution put typename before list<v>::iterator in:
template<typename k, typename v> class hash_table { public: class iterator { private: list<v> list_; // works typename list<v>::iterator it_; // no more fails list<int>::iterator it2_; // works }; //.... } see also: c++ template typename iterator
Comments
Post a Comment