I get an "undefined reference to ..." for two of my functions
<p>I have created three separate files. The first is the main.cpp the 2nd is a header file called "statistics.h" which has the declarations for the two functions i am getting the error and the 3nd is a file called statistics.cpp which holds the implementation of the two functions.</p>

<p>Here is my main file:</p>

<pre><code>#include &lt;iostream&gt;
#include "statistics.h"

using namespace std;

int main()
{
   cout&lt;&lt;"This program provides the average and the standard deviation of 1,2,3 or 4 numbers."&lt;&lt; endl;
   while(true){
   start:
   unsigned int howmany;

   cout&lt;&lt;endl;
   cout&lt;&lt;"How many numbers do u wish to receive as input??  ";
   cin &gt;&gt; howmany;

   if (howmany&gt;4){
   cout&lt;&lt;"You should pick at most 4 numbers u idiot!!!"&lt;&lt; endl&lt;&lt;endl;
   goto start;
   }
   if(howmany==0){
   return 0;


   }
   cout&lt;&lt; endl;
   double nums[howmany];



   for (int i=0;i&lt;howmany;i++){
   cout&lt;&lt;"Give me the number "&lt;&lt;i+1&lt;&lt;":";
   cin&gt;&gt;nums[i];

   }


   double avg=average(nums,howmany);     /////////////////////////////
   double stdev=standard_deviation(nums,howmany,avg);   ////////////////////

   cout&lt;&lt; endl&lt;&lt;"Average: "&lt;&lt;avg&lt;&lt;". Standard Deviation: "&lt;&lt; stdev&lt;&lt; endl;

   }




}
</code></pre>

<p>My header file is:</p>

<pre><code>#ifndef STATISTICS_H_INCLUDED
#define STATISTICS_H_INCLUDED





double average(double ar[],int hm);
double standard_deviation(double ar[],int hm,double avrg);


#endif // STATISTICS_H_INCLUDED
</code></pre>

<p>And my implementation file statistics.cpp is:</p>

<pre><code>#include&lt;iostream&gt;
#include"statistics.h"
#include &lt;math.h&gt;

using namespace std;


double average(double ar[],int hm){


double sum=0.0;
double average;

for(int i=0;i&lt;hm;i++){

sum+=ar[i];

}

average=sum/hm;

return average;

}


double standard_deviation(double ar[],int hm,double avrg){

    double std_dev;
    double sum=0;
    double ans;

    for(int i=0;i&lt;hm;i++){

    sum+= ((ar[i]-avrg)*(ar[i]-avrg));

    }

    ans=sqrt(sum/hm);
    return ans;


}
</code></pre>

<p>I am getting the errors in my main file (i have marked the corresponding lines with consecutive ////////). What could be wrong?? I am sure its something stupid from my part.</p>

<hr>

<p>As i am using codeblocks i finally found the solution. I just needed to add #include "statistics.cpp" to my main.cpp file.</p>
