This is probably really simple, but it's hindering me on my way down c++ road. I am currently reading through accelerated c++ and I decided to overkill one of the exercises. It all worked well and my code ran fine until I split it into a header and separate source file. When I import my .cpp source file containing some functions I wrote, everything runs fine. But when I try to import the functions through a header file it fails horribly and I get the following error. I am compiling with gcc from Geany, it's all worked fine until now. Thanks for any help.
error:
g++ -Wall -o "quartile" "quartile.cpp" (in directory: /home/charles/Temp)
Compilation failed.
/tmp/ccJrQoI9.o: In function `main':
quartile.cpp:(.text+0xfd): undefined reference to `quartile(std::vector<double, std::allocator<double> >)'
collect2: ld returned 1 exit status
"stats.h":
#ifndef GUARD_stats_h
#define GUARD_stats_h
#include <vector>
std::vector<double> quartile(std::vector<double>);
#endif
"stats.cpp":
#include <vector>
#include <algorithm>
#include "stats.h"
using std::vector; using std::sort;
double median(vector<double> vec){
//code...
}
vector<double> quartile(vector<double> vec){
//code and I also reference median from here.
}
"quartile.cpp":
#include <iostream>
#include <vector>
#include "stats.h" //if I change this to "stats.cpp" it works
using std::cin; using std::cout;
using std::vector;
int main(){
//code and reference to quartile function in here.
}