LNK2005: already defined error
<p>I am working on a school assignment, and I get this strange error (I am quite new to C++).</p>

<p>I should find the first value between 1500 and 1900. When I build it the first time, everything is ok, but when I build it the next time, I get this error:</p>

<pre><code>error LNK2005: "bool __cdecl greaterThan1500SmallerThan1900(int)" (?greaterThan1500SmallerThan1900@@YA_NH@Z) already defined in Lab5.obj
</code></pre>

<p>If I then change the code slightly (change the type in the predicate function to double) it builds again one time.</p>

<pre><code>template&lt;typename T&gt;
T MyStlClass&lt;T&gt;::myFindIf(list&lt;T&gt; &amp;theList) {

    list&lt;T&gt;::iterator it = find_if(theList.begin(), theList.end(), greaterThan1500SmallerThan1900);
    return *it;
}

bool greaterThan1500SmallerThan1900(int value){
    return (value &gt;= 1500 &amp;&amp; value &lt;= 1900);
}
</code></pre>

<p>I have read on this site that it is because that I include the ".cpp" file, but on the other hand, I have also read, that I need to include the ".cpp" file, when I am using templates.</p>
