unresolved external symbol when passing a function pointer : <p>I'm trying to create a generic button and I want to be able to pass a function to call when I click it.</p>

<p>main.cpp:</p>

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

int testfunction() {
   print("Test");
   return 1;
}

...other stuff...

window-&gt;SetButtonFunction_NoArgs&lt;int&gt;(" *unrelated stuff* ", &amp;testfunction);
</code></pre>

<p>window is a WindowMain class:</p>

<p>window.h:</p>

<pre><code>class WindowMain {
     *Stuff*
     template &lt;class R1&gt; void SetButtonFunction_NoArgs(string id, R1(*func)());
     *Other Stuff*
};
</code></pre>

<p>window.cpp:</p>

<pre><code>///Find the object of that id and set the fuction to it
template &lt;class R1&gt; void WindowMain::SetButtonFunction_NoArgs(string id,  R1(*func)()) {
    for (int i = 0; i &lt; objects_.size(); i++) {
        if (objects_[i].getId() == id) {
            objects_[i]-&gt;AddButton_NoArgs&lt;R1&gt;(func);
        }
    }
}
</code></pre>

<p>The problem is here somewhere I think but I can't find it... When I try to compile it gives me this:</p>

<pre><code>1&gt;main.obj : error LNK2019: unresolved external symbol "public: void __cdecl WindowMain::SetButtonFunction_NoArgs&lt;int&gt;(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt;,int (__cdecl*)(void))" (??$SetButtonFunction_NoArgs@H@WindowMain@@QEAAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@P6AHXZ@Z) referenced in function "void __cdecl Create(void)" (?Create@@YAXXZ)
</code></pre>

<p>Thanks for help!</p>
