title: c++ iterator with template
body: <p>I have a problem about how to use iterator under the template manner.<br>
  Here is an example I am trying to do, the problem is that, inside the for loop how can I initial the iterator pp ?<br>
  <br>
  I have read a similar question, but I cannot fully understand that since I am a beginner.<br>
  <a href="https://stackoverflow.com/questions/2219146/what-should-the-iterator-type-be-in-this-c-template">What should the iterator type be in this C++ template?</a><br>
  Can anyone help and also provide some simple explanation?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  template &lt;class T&gt;
  void my_print(std::vector&lt;T&gt; input){
      for(std::vector&lt;T&gt;::iterator pp = input.begin(); pp != input.end(); ++pp)
          std::cout &lt;&lt; *pp &lt;&lt; "\n";
  }
  int main(int argc,char* argv[]){
      std::vector&lt;int&gt; aa(10,9);
      my_print(aa);
  
      return 0;
  }
  </code></pre>
  
  <p>error message I got:<br>
  ‘std::vector::iterator’ is parsed as a non-type, but instantiation yields a type</p>