LNK2019 - why unresolved external with template friend function
问题 I don't get this error: #include <iostream> using namespace std; // LNK2019f.cpp // LNK2019 expected template<class T> void f(T) {} template<class T> struct S { friend void f(T); // try the folowing line instead // friend void f<T>(T); }; int main() { S<int> s; int a = 2; f(a); // unresolved external } Taken from http://msdn.microsoft.com/en-us/library/799kze2z(v=vs.80).aspx Why does the error not show up if I comment out S< int > s ? I got that I need to declare the template argument list as