As StatTool1D<> is a templated class, the implemention must also be in the header.
i.e. move the contents of stattest1d.cpp into stattest1d.h and ditch the .cpp file.
(the compiler needs to see the whole definition of a templated class at the point of instantiation, not just the declaration.)
PS also note you're using a C99-ism -- non-const array sizes -- which is not ANSI compliant for C++03 or C++11. GCC les you gt away it when you're not compiling in ANSI mode, but if you want to be cross-platform you need to eliminate this.
Give your current code, you could just make line 6 of stattest.cpp
PPS Also, out of interest, where is std::cout coming from? I see no sign of <iostream> ??
Thank you very much Andy. I wasn't aware that splitting a templated class doesn't work.
But after thinking about it, it does make sense.
I hope my train of thought is right.
Is it true that the compiler can't link StatTool1D.h and StatTool1D.cpp because the data type is yet to be defined?
So the compiler doesn't know how much memory to reserve?
Careful with you terminolgy: you're never going to link a .h or .cpp file.
It's not about the reservation of memory as such, but it does have to know the memory layout of the class. Which is how much memory it would have to allocate for an instance of a class. And about types (in you case, just the one: T)
When the compiler parses a template definition, it stores the definition away somewhere. Then when you instantiate it (when you use it in stattest.cpp), it has to create (or generate) the actual implementations (in your case, a StatTool1D of ints and a StatTool1D of double.) As far as the object code goes, you might as well have written two version of StatTool1D -- StatTool1D_Int and StatTool1D_Doub. Except programmers are "lazy", so we use templating!
To generate the int and double versions, it must know all about the classes. Partly because it must know the memory layout of the class, as I've already said (though, as it happens, you're using a pointer for you data storage, so the generated types will have the same memory layout and size.) But also because the compiler must know about the template's types (T, etc) to generate the methods.
It looks like the compiler might have been able to get away without knowing the method definitions up front, given how little you do in them. But as the compiler is not prescient, so it has to allow for the fact that you might have used variables of type T in your methods.
PS Actually, templating it is less prone to bugs than cut and paste, too.