没有特殊要求,文件扩展名必须为 .cpp (C++)!// Example of the template keyword
template <class T, int i> class TestClass {
public:
   char buffer[i];
   T testFunc(T* p1 );
};template <class T, int i>
T TestClass<T,i>::testFunc(T* p1) {
    return *(p1++)
};// To create an instance of TestClass
TestClass<char, 5> ClassInst;

解决方案 »

  1.   

    我把msdn的一段给贴在这里.
    template < [typelist] [, [ arglist ]] > declarationThe template declaration specifies a set of parameterized classes or functions.The template parameter list is a comma-separated list of types (in the form class identifier or typename identifier) or a non-type to be used in the template body. The declaration field must be a declaration of a function or class.You can instantiate a class template much like you would instantiate a normal class, but include the template arguments within angle brackets. No special syntax is required to call a function template.