Note that there are some explanatory texts on larger screens.

plurals
  1. POfatal error LNK1120: 1 unresolved externals
    text
    copied!<p>I am compiling the following code and I am receiving an error. I want to practice templates in boost and I do not know how to handle this problem </p> <pre><code>#include &lt;stdafx.h&gt; #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;boost/function.hpp&gt; #include &lt;boost/array.hpp&gt; using namespace std; template&lt;typename R,typename D&gt; class GenericFunction { private: boost::function&lt;R (D)&gt; f; protected: GenericFunction(); public: GenericFunction(const boost::function&lt;R (D)&gt;&amp; myFunction); R evaluate(const D&amp; value) const ; R operator ()(const D&amp; value) const; }; template &lt;typename R, typename D, int N&gt; class ScalarValuedFunction:public GenericFunction&lt;R,boost::array&lt;D, N&gt;&gt; { public: ScalarValuedFunction(const boost::function&lt;R (const boost::array&lt;D, N&gt;)&gt; &amp;myF); }; template&lt;typename Numeric, std::size_t N&gt; Numeric Norm(const boost::array&lt;Numeric , N&gt;&amp; Vec) { Numeric Result=Vec[0]*Vec[0]; for (std::size_t i=1; i&lt;Vec.size();i++) { Result+=Vec[i]*Vec[i]; } return Result; } int main () { const int N=4; boost::array&lt;double, N&gt; arr={0.2,.3,1.1,4}; ScalarValuedFunction&lt;double, double, N&gt; myfun(Norm&lt;double,N&gt;); } </code></pre> <p>and receiving the following error,</p> <pre><code>ConsoleApplication2.obj : error LNK2019: unresolved external symbol "public: __thiscall ScalarValuedFunction&lt;double,double,4&gt;::ScalarValuedFunction&lt;double,double,4&gt;(class boost::function&lt;double __cdecl(class boost::array&lt;double,4&gt;)&gt; const &amp;)" (??0?$ScalarValuedFunction@NN$03@@QAE@ABV?$function@$$A6ANV?$array@N$03@boost@@@Z@boost@@@Z) referenced in function _main 1&gt;c:\users\university\documents\visual studio 2012\Projects\ConsoleApplication2\Debug\ConsoleApplication2.exe : fatal error LNK1120: 1 unresolved externals </code></pre> <p>please someone tell me what is wrong with my code? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload