title: implementing a C++ postfix increment operator
body: <p>I compiled the following example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iterator&gt;
  using namespace std;
  
  class myiterator : public iterator&lt;input_iterator_tag, int&gt;
  {
    int* p;
  public:
    myiterator(int* x) :p(x) {}
    myiterator(const myiterator&amp; mit) : p(mit.p) {}
    myiterator&amp; operator++() {++p;return *this;}
    myiterator&amp; operator++(int) {myiterator tmp(*this); operator++(); return tmp;}
    bool operator==(const myiterator&amp; rhs) {return p==rhs.p;}
    bool operator!=(const myiterator&amp; rhs) {return p!=rhs.p;}
    int&amp; operator*() {return *p;}
  };
  
  int main () {
    int numbers[]={10,20,30,40,50};
    myiterator beginning(numbers);
    myiterator end(numbers+5);
    for (myiterator it=beginning; it!=end; it++)
        cout &lt;&lt; *it &lt;&lt; " ";
    cout &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>
  
  <p>from <a href="http://www.cplusplus.com/reference/std/iterator/iterator/" rel="noreferrer">cplusplus.com/reference</a> and I get the compiler warning:</p>
  
  <pre><code>iterator.cpp: In member function 'myiterator&amp; myiterator::operator++(int)':
  iterator.cpp:13: warning: reference to local variable 'tmp' returned
  </code></pre>
  
  <p>What's wrong here? Is the postfix signature supposed to be <code>myiterator operator++(int)</code> i.e. return by value?</p>
  
  <p>Is there somewhere defined what the postfix signature should look like on STL iterators?</p>