making a makefile for a template class
<p>So i have couple of files that I want to compile together one of them is stack.h with stack.cpp
thats my header file:</p>

<pre><code>#include&lt;iostream&gt;
#ifndef STACK_H
#define STACK_H 
template &lt;class ItemType&gt;
class StackType
{
public:
    //code


private:
    //code   
};
#include "stack.cpp"
#endif
</code></pre>

<p>then i have stack.cpp</p>

<pre><code>#include "stack.h"
#include &lt;iostream&gt;
using namespace std;

template&lt;class ItemType&gt;
StackType&lt;ItemType&gt;::StackType(){
    top = -1;
    MAX_ITEMS = 200;
}

//other codes
}
</code></pre>

<p>but it says that I am redefining the code in stack.cpp</p>

<p>thats my makefile</p>

<pre><code>main.o: main.cpp stack.h
    g++ $(CFLAGS) -c -o main.o main.cpp
stack.o: stack.cpp stack.h
    g++ $(CFLAGS) -c -o stack.o stack.cpp
</code></pre>

<p>I don't see what the problem is.</p>
