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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -