title: C++ error with classes: expected initializer before '*':
body: <p>I'm implementing a list (just for fun):</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  template &lt;class T&gt;
  class list {
  
  private:
      struct node {
          T data;
          struct node *next, *prev;
      } head;
  
      unsigned int length;
  
  public:
  
      class iterator {
  
      private:
          node *ptr;
  
      public:
          iterator ();
          inline T&amp; operator *();
          inline iterator operator ++();
          inline iterator operator ++(int);
          inline iterator operator --();
          inline iterator operator --(int);
  
      };
  
      list ();
      //~list ()
  
      inline unsigned int size () const;
      inline bool empty () const;
      inline iterator begin ();
      inline iterator end ();
      inline T&amp; front ();
      inline T&amp; back ();
      //void insert (iterator position, const T &amp;x);
      //void push_back (const T &amp;x);
      //void push_front (const T &amp;x);
      //void pop_back ();
      //void pop_front ();
  
  };
  
  template &lt;class T&gt;
  inline list&lt;T&gt;::iterator::iterator () {
  
      ptr = NULL;
  
  }
  
  template &lt;class T&gt;
  inline T&amp; list&lt;T&gt;::iterator::operator*() {
  
      return ptr-&gt;data;
  
  }
  
  
  template &lt;class T&gt;
  inline iterator list&lt;T&gt;::iterator::operator++() {
  
      ptr = ptr-&gt;next;
      return *this;
  
  }
  
  template &lt;class T&gt;
  inline iterator list&lt;T&gt;::iterator::operator++(int) {
  
      iterator tmp = ptr;
      ptr = ptr-&gt;next;
      return tmp;
  
  }
  
  template &lt;class T&gt;
  inline iterator list&lt;T&gt;::iterator::operator --() {
  
      ptr = ptr-&gt;prev;
      return *this;
  
  }
  
  template &lt;class T&gt;
  inline iterator list&lt;T&gt;::iterator::operator --(int) {
  
      iterator tmp = ptr;
      ptr = ptr-&gt;prev;
      return tmp;
  
  }
  
  ////////////////////
  ////////////////////
  
  template &lt;class T&gt;
  inline list&lt;T&gt;::list () {
  
      head.next = &amp;head;
      head.prev = &amp;head;
      length = 0;
  
  
  }
  
  template &lt;class T&gt;
  inline unsigned int list&lt;T&gt;::size () const {
  
      return length;
  
  }
  
  template &lt;class T&gt;
  inline bool list&lt;T&gt;::empty () const {
  
      return length == 0;
  
  }
  
  template &lt;class T&gt;
  inline iterator list&lt;T&gt;::begin () {
  
      return head-&gt;next;
  
  }
  
  template &lt;class T&gt;
  inline iterator list&lt;T&gt;::end () {
  
      return &amp;head;
  
  }
  
  template &lt;class T&gt;
  inline T&amp; list&lt;T&gt;::front () {
  
      return *begin();
  
  }
  
  template &lt;class T&gt;
  inline T&amp; list&lt;T&gt;::back () {
  
      return *(--end());
  
  }
  </code></pre>
  
  <p>And I'm getting this errors:</p>
  
  <pre><code>list.h:64: error: expected initializer before ‘list’
  list.h:72: error: expected initializer before ‘list’
  list.h:81: error: expected initializer before ‘list’
  list.h:89: error: expected initializer before ‘list’
  list.h:125: error: expected initializer before ‘list’
  list.h:132: error: expected initializer before ‘list’
  </code></pre>
  
  <p>No, i'm not missing a semi-colon.</p>
  
  <p>Any idea?</p>