title: Error: need ‘typename’ before iterator
body: <p>Hey guys i have this code:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;string&gt;
  #include&lt;list&gt;
  #include&lt;vector&gt;
  
  template&lt;class T&gt;
  class ListLib {
  public:
      ListLib(std::list&lt;T&gt;&amp; listItem) {
          *listT = listItem;
      }
  
      std::vector&lt;T&gt; convertToVector() {
          std::vector&lt;T&gt; result;
          std::list&lt;T&gt;::iterator itList;
  
          for (itList = *listT-&gt;begin(); itList != *listT-&gt;end(); itList++)
              result-&gt;(*itList);
  
          std::vector&lt;T&gt;::iterator itVec;
          for (itVec = result.begin(); itVec != result.end())
              std::cout &lt;&lt; *itVec &lt;&lt; std::endl;
      }
  private:
      std::list&lt;T&gt; *listT;
  };
  
  int main() {
      std::list&lt;std::string&gt; sampleList;
      std::vector&lt;std::string&gt; sampleVector;
      sampleList.push_back("3");
      sampleList.push_back("4");
      sampleList.push_back("5");
      sampleList.push_back("6");
  
      ListLib&lt;std::string&gt; listLib(sampleList);
      std::cout &lt;&lt; "Hello World" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>And i tried to resolve many errors i got with this, but led to no good!I made a function that does same thing as libary im making now with a class. i need help! Here is error:</p>
  
  <pre><code>/home/ubuntu/workspace/c++/CustomLibaries/listLib.cpp: In member function ‘std::vector&lt;T&gt; ListLib&lt;T&gt;::convertToVector()’:                                                                                                                 
  /home/ubuntu/workspace/c++/CustomLibaries/listLib.cpp:15:3: error: need ‘typename’ before ‘std::list&lt;T&gt;::iterator’ because ‘std::list&lt;T&gt;’ is a dependent scope                                                                            
     std::list&lt;T&gt;::iterator itList;                                                                                    
     ^                                                                                                                 
  /home/ubuntu/workspace/c++/CustomLibaries/listLib.cpp:15:26: error: expected ‘;’ before ‘itList’                     
     std::list&lt;T&gt;::iterator itList;                                                                                    
                            ^                                                                                          
  /home/ubuntu/workspace/c++/CustomLibaries/listLib.cpp:17:8: error: ‘itList’ was not declared in this scope           
     for (itList = *listT-&gt;begin(); itList != *listT-&gt;end(); itList++)                                                 
          ^                                                                                                            
  /home/ubuntu/workspace/c++/CustomLibaries/listLib.cpp:18:12: error: expected unqualified-id before ‘(’ token         
      result-&gt;(*itList);                                                                                               
              ^                                                                                                        
  /home/ubuntu/workspace/c++/CustomLibaries/listLib.cpp:20:3: error: need ‘typename’ before ‘std::vector&lt;T&gt;::iterator’ because ‘std::vector&lt;T&gt;’ is a dependent scope                                                                        
     std::vector&lt;T&gt;::iterator itVec;                                                                                   
     ^                                                                                                                 
  /home/ubuntu/workspace/c++/CustomLibaries/listLib.cpp:20:28: error: expected ‘;’ before ‘itVec’                      
     std::vector&lt;T&gt;::iterator itVec;                                                                                   
                              ^                                                                                        
  /home/ubuntu/workspace/c++/CustomLibaries/listLib.cpp:21:8: error: ‘itVec’ was not declared in this scope            
     for (itVec = result.begin(); itVec != result.end())                                                               
          ^
  /home/ubuntu/workspace/c++/CustomLibaries/listLib.cpp:21:53: error: expected ‘;’ before ‘)’ token
     for (itVec = result.begin(); itVec != result.end())
                                                       ^
  </code></pre>