title: postfix operators linked list generic node iterator
body: <p>I am trying to iterate through a linked list node iterator. The code has shown no error in compilation, however, the data placed in the linked lists node does not print. Here are the codes.</p>
  
  <pre><code>#pragma once
  using namespace std;
  
  template &lt;class T&gt;
  class ListNode {
  public:
      T fData;
      ListNode* fNext;
  
      ListNode(const T&amp; aData, ListNode* aNext = (ListNode*)0) {
          fData = aData;
          fNext = aNext;
      }
  };
  </code></pre>
  
  <p>The ListNodeTemplate to instantiate a Node.</p>
  
  <pre><code>#pragma once
  #include "ListNodeTemplate.h"
  
  using namespace std;
  
  template &lt;class T&gt;
  class ListNodeIterator
  {
  private:
      ListNode&lt;T&gt;* fNode;
  public:
      typedef ListNodeIterator&lt;T&gt; Iterator;
      ListNodeIterator(ListNode&lt;T&gt;* aNode);
      const T&amp; operator*() const;
      Iterator&amp; operator++();
      Iterator operator++(int);
      bool operator==(const Iterator&amp; aOther) const;
      bool operator!=(const Iterator&amp; aOther) const;
      Iterator end();
  
  };
  </code></pre>
  
  <p>The ListNodeIterator header file, you can see that the ListNodeTemplate is included in the header file of the iterator.</p>
  
  <pre><code>#include "pch.h"
  #include "ListNodeIterator.h"
  
  using namespace std;
  
  template &lt;class T&gt;
  ListNodeIterator&lt;T&gt;::ListNodeIterator(ListNode&lt;T&gt;* aNode) {
      fNode = aNode;
  }
  template &lt;class T&gt;
  const T&amp; ListNodeIterator&lt;T&gt;::operator*() const {
      return fNode-&gt;fData;
  }
  
  template &lt;class T&gt;
  typename ListNodeIterator&lt;T&gt;::Iterator&amp; ListNodeIterator&lt;T&gt;::operator++() { //prefix
      fNode = fNode-&gt;fNext;
      return *this;
  }
  
  template &lt;class T&gt;
  typename ListNodeIterator&lt;T&gt;::Iterator ListNodeIterator&lt;T&gt;::operator++(int) { //postfix
      ListNodeIterator&lt;T&gt; temp = *this;
      fNode = fNode-&gt;fNext;
      return temp;
  }
  
  template &lt;class T&gt;
  bool ListNodeIterator&lt;T&gt;::operator==(const Iterator&amp; aOther) const {
      return (fNode == aOther.fNode);
  }
  
  template &lt;class T&gt;
  bool ListNodeIterator&lt;T&gt;::operator!=(const Iterator&amp; aOther) const {
      return !(*this == aOther.fNode);
  }
  
  template &lt;class T&gt;
  typename ListNodeIterator&lt;T&gt;::Iterator ListNodeIterator&lt;T&gt;::end() {
      return *this = nullptr;
  }
  </code></pre>
  
  <p>What I identified so far is that postfix operator doesn't seem to iterate the linked list node. The compiler has shown no compile errors.</p>
  
  <p>Here is the main.cpp</p>
  
  <pre><code>#include "pch.h"
  #include &lt;iostream&gt;
  #include "ListNodeIterator.cpp"
  using namespace std;
  int main()
  {
      typedef ListNode&lt;int&gt; IntegerNode;
      IntegerNode One(1);
      IntegerNode Two(2, &amp;One);
      IntegerNode Three(3, &amp;Two);
  
      for (ListNodeIterator&lt;int&gt; iter(&amp;Three); iter != iter.end(); ++iter) {
          cout &lt;&lt; "Value " &lt;&lt; *iter &lt;&lt; endl;
      }
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>So far it print nothing.</p>
  
  <p>My expected output is:</p>
  
  <pre><code>Value 3
  Value 2
  Value 1
  </code></pre>
  
  <p>Any advice on what the issue is and how to improve upon it?</p>