I have two quick tips that may save you some problems in the future.
Templates must be defined and implemented in headers, because they are translated/created at compile-time
If you have the following code:
// Foo.h
template
class Foo
{
...
};
// Bar.cpp
#include "Foo.h"
void func()
{
Foo fooInt;
Foo fooDouble;
}
When processing the Bar.cpp file, the compiler will "create" a new definition of the Foo class with every T replaced with the int type for the fooInt instance, and a new definition of the Foo class with every T replaced with the double type for the fooDouble instance.
In a nutshell, C++ does not support template classes, the compiler emulates them replacing the types at compile time and creating normal classes. So, the compiled type of fooInt and fooDouble are different.
Because they are translated at compile-time and not compiled individually, they must be defined and implemented in headers.
If you implement the template class as a normal class (header and source file) the error thrown by the compiler (the linker actually) is that there is no method implemented (it's because the source file is ignored).
You can still create forward declarations to avoid cyclic dependencies
It's just that you have to forward declare them like this:
template
class Foo;
And, as with normal forward declarations, you have to be sure that you are including all the headers necessary.