Missing symbol error (undefined reference)
<p>I have trying to define a class DS with the declaration in DS.h and implementation at DS.cpp
The code is very small so here is the listing:</p>

<pre><code> /*
  * DS.h
  */

 #ifndef DS_H_
 #define DS_H_

 #include "Node.h"

 template&lt;class T&gt;
 class DS
 {
     public:
         static const int BST;
         static const int SLL;
         static const int DLL;

         DS(const int);
         ~DS();

     private:
         int m_type;
         Node&lt;T&gt; *head;
 };

 #endif /* DS_H_ */
</code></pre>

<p>And,</p>

<pre><code> /*
  * DS.cpp
  */

 #include "DS.h"

 template&lt;class T&gt; const int DS&lt;T&gt;::BST = 0;
 template&lt;class T&gt; const int DS&lt;T&gt;::SLL = 1;
 template&lt;class T&gt; const int DS&lt;T&gt;::DLL = 2;

 template&lt;class T&gt;
 DS&lt;T&gt;::DS(const int type) :
     m_type(type), head(0)
 {
 }

 template&lt;class T&gt;
 DS&lt;T&gt;::~DS()
 {
 }
</code></pre>

<p>The main program is:</p>

<pre><code> #include "DS.h"

 int main()
 {
     DS&lt;int&gt; *sll1 = new DS&lt;int&gt; (DS&lt;int&gt;::SLL);
     delete sll1;
     return 0;
 }
</code></pre>

<p>When I try to compile this program, I get the following error:</p>

<pre><code> g++ -O2 -g -Wall -Wextra -Weffc++ -fmessage-length=0   -c -o Node.o Node.cpp
 g++ -O2 -g -Wall -Wextra -Weffc++ -fmessage-length=0   -c -o DS.o DS.cpp
 g++ -O2 -g -Wall -Wextra -Weffc++ -fmessage-length=0   -c -o main.o main.cpp
 DS.h: In instantiation of ?DS&lt;int&gt;?:
 main.cpp:13:   instantiated from here
 DS.h:15: warning: ?class DS&lt;int&gt;? has pointer data members
 DS.h:15: warning:   but does not override ?DS&lt;int&gt;(const DS&lt;int&gt;&amp;)?
 DS.h:15: warning:   or ?operator=(const DS&lt;int&gt;&amp;)?
 g++ -o ds.exe Node.o DS.o main.o 
 main.o: In function `main':
 /cygdrive/c/Documents and Settings/ansrivastava/My Documents/src/ds/main.cpp:13: undefined reference to `DS&lt;int&gt;::SLL'
 /cygdrive/c/Documents and Settings/ansrivastava/My Documents/src/ds/main.cpp:13: undefined reference to `DS&lt;int&gt;::DS(int)'
 /cygdrive/c/Documents and Settings/ansrivastava/My Documents/src/ds/main.cpp:14: undefined reference to `DS&lt;int&gt;::~DS()'
 collect2: ld returned 1 exit status
 make: *** [ds.exe] Error 1
</code></pre>

<p>Now, if I remove all the code from DS.cpp and paste it into DS.h, everything compiles fine. Any idea what am I doing wrong?</p>
