No definition available for static const member with initializer?
问题 Given: template<class T> struct S { static int const N = 1; }; extern template class S<int>; template<class T> int f( T n ) { return n + S<T>::N; // line 10 } int main() { return f(1); // line 14 } //template class S<int>; // intentionally commented out to trigger error I get: foo.cpp: In function ‘int f(T) [with T = int]’: foo.cpp:10: instantiated from ‘const int S<int>::N’ foo.cpp:10: instantiated from ‘int f(T) [with T = int]’ foo.cpp:14: instantiated from here foo.cpp:10: error: explicit