I get an linker error (2001, unresolved external symbol) with the following code. It only happens with templates, i can perfectly do the same thing with void, int, etc.
//a.h
template<typename T> T foo( DWORD );
//a.cpp
#include "a.h"
template<typename T> T foo( DWORD bar )
{
return T();
}
//main.cpp
#include "a.h"
void something()
{
int hello = foo<int>( 1 );
}
It does work when i put the declaration of foo inside the header file like this
//a.h
template<typename T> T foo( DWORD bar )
{
return T();
}