title: How to compile a templated class (C++) in Eclipse?
body: <p>I'm trying to create a linked list class in Eclipse but I can't get it to compile properly.</p>
  
  <p>Here is my .cc file (code snipet)</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "list.h"
  
  using namespace std;
  
  template &lt;class T&gt;
  bool List&lt;T&gt;::isEmpty()
  {
      return (firstNode == NULL);
  }
  </code></pre>
  
  <p>and here is my list.h file (code snipet)</p>
  
  <pre><code>#ifndef __LIST_H__
  #define __LIST_H__
  
  template &lt;typename T&gt;
  class List {
  
  public:
  
      bool isEmpty();
  
   private:
      struct node {
      node   *following;
      node   *previous;
      T      *contents;
      };
  
      node   *firstNode;
  };
  
  #include "list.cc"
  
  #endif /* __LIST_H__ */
  </code></pre>
  
  <p>I try "Building All" in eclipse but I get the following error:</p>
  
  <pre><code>make all 
  Building file: ../list.cc
  Invoking: Cross G++ Compiler
  g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"list.d" -MT"list.d" -o "list.o"     "../list.cc"
  ../list.cc:13: error: redefinition of 'bool List&lt;T&gt;::isEmpty()'
  ../list.cc:13: error: 'bool List&lt;T&gt;::isEmpty()' previously declared here
  make: *** [list.o] Error 1
  </code></pre>
  
  <p>Help please...thanks.  I'll be happy to provide any clarifications needed</p>
  
  <p>EDIT: I was given the .h file so I know that it is correct.  I also know that I am supposed to have a .cc file called list.cc (it is included at the end of the .h file)</p>