title: Increment operator/ iterator implementation
body: <p>I am trying to figure out a couple of things here:</p>
  
  <ol>
  <li>How do I write an increment operator for a node class that has a pointer to the next node?</li>
  <li><p>How do I implement iterators for a class like below?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  template &lt;typename T&gt;
  class Node {
  public:
      Node(int i=0):val(i) {}
      Node*&amp; operator++(int i=0) {return next;};
  
      T val;
      Node *next;
  };
  
  //================================================
  int main() {
  
      Node&lt;int&gt; *head, *tmp1, *tmp2;
  
      tmp1 = new Node&lt;int&gt;(0); 
      head = tmp1;
  
      for (int i=1; i&lt;10; ++i) {
  
          tmp2 = new Node&lt;int&gt;(i);
          tmp1-&gt;next = tmp2;
          tmp1 = tmp2;
      }
  
      while (head != NULL) {
  
          cout &lt;&lt; head-&gt;val &lt;&lt; " '";
          head = head-&gt;operator++(0);    //How do I make it work with ++head;?
      }
  }
  </code></pre></li>
  </ol>
  
  <p>This is not a good example for demonstrating operator overloading or iterators.</p>