title: One function to print vector and list in c++
body: <p>While studying Standard Template Library </p>
  
  <pre><code>/*
  Aim:Create a vector of integers. Copy it into a list, reversing as you 
  do so.
  */
  
  #include&lt;iostream&gt;
  #include&lt;vector&gt;
  #include&lt;algorithm&gt;
  #include&lt;list&gt;
  using namespace std;
  template&lt;typename t&gt;
  void print(vector &lt;t&gt; &amp;v)      //what changes need to be done here?
  {
      for (auto it = v.begin(); it &lt; v.end(); it++)
      {
          cout &lt;&lt; *it &lt;&lt; " ";
      }
      cout &lt;&lt; endl;
  }
  int main()
  {
      vector&lt;int&gt; v;
      v.push_back(1);
      v.push_back(2);
      v.push_back(3);
      v.push_back(4);
      print(v);         
      list&lt;int&gt; l(v.size());
      reverse_copy(v.begin(), v.end(), l.begin());
      print(l);        //cannot call this
  }
  </code></pre>
  
  <p>The problem is i want the same function <code>print()</code> to print the vector as well as the list for me.
  I tried doing the following</p>
  
  <pre><code>void print(t &lt;t&gt; &amp;v);
  </code></pre>
  
  <p>Can we do this? I have also seen the solutions using the ostream iterator 
  for printing the containers.Would that be a solution to my problem?</p>