title: C++ list iterator
body: <p>I am trying to iterate over the list using the iterator. The requirement is to get the previous element of a given element. But the condition is not to use two different iterators. I tried using prev(), but my professor said not use this function. Is there any other way for this?</p>
  
  <p>My code is like this:</p>
  
  <pre><code>int main ()
  {
    int myints[] = {75,23,65,42,13};
    std::list&lt;int&gt; mylist (myints,myints+5);
  
    std::cout &lt;&lt; "mylist contains:";
    for (std::list&lt;int&gt;::iterator it=mylist.begin(); it != mylist.end(); ++it)
    //Print the current element
    //Print the previous element
  
  
    return 0;
  }
  </code></pre>