这些错误是由于您的模板定义对用户代码不可见造成的。模板定义应该在以下地方声明: 与模板声明一起在头文件中 在用户代码使用它的.cpp文件中。但是,在这种方法中,定义只对使用它的.cpp文件可见。请参见下面的示例。 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