title: invalid initialization of non-const reference of type ‘int&' from a temporary of type 'MyClass<int>::iterator*'
body: <p>I'm getting the following error from g++ while trying to add iterator support for my linked list class.</p>
  
  <blockquote><pre>
  LinkedList.hpp: In member function ‘Type&amp; exscape::LinkedList&lt;Type&gt;::iterator::operator*() [with Type = int]’:  
  tests.cpp:51:   instantiated from here  
  LinkedList.hpp:412: error: invalid initialization of non-const reference of type ‘int&amp;’ from a temporary of type ‘exscape::LinkedList&lt;int&gt;::iterator*’
  </pre></blockquote>
  
  <p>Likely relevant code snippets:</p>
  
  <p>LinkedList.hpp:</p>
  
  <pre><code>template &lt;typename Type&gt;
  class LinkedList {
      private:
          struct node {
              struct node *prev;
              struct node *next;
              Type data;
          };
      public:
          class iterator : public std::iterator&lt;...&gt; {
              node *p;
  
          public:
               Type &amp;operator*();
          };
  ...
  };
  
  template &lt;typename Type&gt;
  LinkedList&lt;Type&gt;::iterator::iterator(struct node *in_node) : p(in_node) {}
  
  template &lt;typename Type&gt;
  inline Type &amp;LinkedList&lt;Type&gt;::iterator::operator*() {
      return this-p-&gt;data; ///// Line 412
  }
  </code></pre>
  
  <p>tests.cpp:</p>
  
  <pre><code>...
  LinkedList&lt;int&gt; l1;
  ...
  LinkedList&lt;int&gt;::iterator it;
  for (it = l1.begin(); it != l1.end(); ++it) {
      std::cout &lt;&lt; "Element: " &lt;&lt; *it &lt;&lt; std::endl; ///// Line 51
  }
  </code></pre>
  
  <p>I've googled (and searched SO, of course), and checked my code to no avail - either I'm missing something basic (aka. doing something stupid), or I'm missing the knowledge required. Any advice?</p>