This errors are happening because, your template
definitions are not visible to the user code. Template definition should be declared in,
- Header file, along with the template
declarations
- In the .cpp file, where the user
code uses it. However in this
approach the definition will be
visible only to the .cpp which uses
it. See below example
test.h
template<typename T>
void foo (T*);
test.cpp
int main ()
{
foo(1);
}
template<typename T>
void foo (T *p)
{
...
}
test2.cpp
// This file can not see the definition of foo