title: Cannot pass function pointer to function declared in header file
body: <p>Okay so I am relatively new to c++ and I am trying to figure out how to use function pointers.  I have a function which is a simple numerical integration and I am trying to pass to it which function to integrate and what the limits of integration are.  I am doing this in Xcode and the error is in the main code saying "no matching function to call SimpsonIntegration".  If someone could please help I would appreciate it.  Also since I am learning, any other criticism will be appreciated as well.  The main.cpp function is below.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "simpson7.h"
  #include &lt;cmath&gt;
  
  using namespace std;
  
  
  
  int main(int argc, const char * argv[])
  {
      double a=0;
      double b=3.141519;
      int bin = 1000;
  
      double (*sine)(double);
      sine= &amp;sinx;
  
  
  
      double n = SimpsonIntegration(sine, 1000, 0, 3.141519);
  
        cout &lt;&lt; sine(0)&lt;&lt;"  "&lt;&lt;n;
  }
  </code></pre>
  
  <p>The simpson.h file is below:</p>
  
  <pre><code>#ifndef ____1__File__
  #define ____1__File__
  
  #include &lt;iostream&gt;
  template &lt;typename mytype&gt;
  
   double SimpsonIntegration(double (*functocall)(double) ,int bin, double a, double b);
   extern double (*functocall)(double);
   double sinx(double x);
  
  #endif /* defined(____1__File__) */
  </code></pre>
  
  <p>The simpson.cpp file is next:</p>
  
  <pre><code>#include "simpson7.h"
  #include &lt;cmath&gt;
  #include &lt;cassert&gt;
  
  
  //The function will only run if the number of bins is a positive integer.
  
  
  
  double sinx(double x){
  
      return sin(x);
  }
  
  double SimpsonIntegration( double (*functocall)(double),  int bin, double a, double b){
  
      assert(bin&gt;0);
      //assert(bin&gt;&gt;check);
  
      double integralpart1=(*functocall)(a), integralpart2=(*functocall)(b);
      double h=(b-a)/bin;
      double j;
  
      double fa=sin(a);
      double fb=sin(b);
  
      for (j=1; j&lt;(bin/2-1); j++) {
          integralpart1=integralpart1+(*functocall)(a+2*j*h);
      }
  
      for (double l=1; l&lt;(bin/2); l++) {
          integralpart2=integralpart2+(*functocall)(a+(2*l-1)*h);
      }
  
      double totalintegral=(h/3)*(fa+2*integralpart1+4*integralpart2 +fb);
  
  
  
      return totalintegral;
  
  }
  </code></pre>
  
  <p>Well okay now that I fixed that silly error I tried to compile and I got this error: "Linker command failed with exit code 1".  </p>