In "header.h"
template <typename T> struct Foo
{
void func();
};
In "Source2.cpp"
#include "Header.h"
#include <iostream>
template <typename T>
void Foo<T>::func()
{
T a = 5;
std::cout << a;;
}
In "Source1.cpp"
#include "Header.h"
template struct Foo<int>;
int main()
{
Foo<int> b;
b.func();
}
Linker error: LNK2019 unresolved external symbol "public: void __thiscall Foo::func(void)" (?func@?$Foo@H@@QAEXXZ) referenced in function _main
Is this not the right way to explicitly instantiate a class?