title: How to properly declare a self-referencing template type?
body: <p>How do I declare a templated type that refers to itself?</p>
  
  <pre><code>template &lt;class T = Animal&gt; class Animal
  {
  public:
      T getChild ();
  }
  </code></pre>
  
  <p>With this, I get a compiler error concerning a missing type specifier. I tried to forward-declare <code>Animal</code>, without success.</p>
  
  <p>I am trying to impose a type constraint. A <code>Lion</code> can only have a <code>Lion</code> as a child, a <code>Bear</code> has a <code>Bear</code>, and so on.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'll post part of the actual class. It is a template for classes that can appear in a linked list:</p>
  
  <pre><code>template &lt;class T = Linked&lt;T&gt; &gt; class Linked
  {
  private:
      T* m_prev;
      T* m_next;
  }
  </code></pre>
  
  <p>I want to enforce that the class can only point to object of the same class (or a subclass).</p>