I am writing a template class for an array of objects, call it arrayobjclass, which holds pointers to other objects, specifically to other arrays in my implementation. The a
Define your function templates in the header. Compiler needs to see them.
Cheers & hth.,
You can't put template declarations in .cpp files like that. Template declarations and implementation need to be visible in the same translation unit. Put template implementations in headers that you #include directly.
For anyone passing by
you can also #include the implementation files in main
in main:
#include "arrayobjclass.h"
#include "arrayclass.h"
#include "arrayobjclass.cpp"
#include "arrayclass.cpp"
Because templates are compiled when required, this forces a restriction for multi-file projects: the implementation (definition) of a template class or function must be in the same file as its declaration. That means that we cannot separate the interface in a separate header file, and that we must include both interface and implementation in any file that uses the templates.
From http://www.cplusplus.com/doc/tutorial/templates/