有这样的函数定义:template<>template<>void object::test<1>(){}有双重template 是什么意思?编辑:我提取了对本示例有效的代码:#include <iostream>template <class U>class A { template <int n> void test() { }};template <class T>class B {public: typedef A<T> object;};typedef B<int>::object object;template<>template<>void object::test < 1 > () {}int main() { return 0;}该代码在g++下编译。资料来源:TUT test framework (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 例如,template<class T = int> // Default T is intclass object<T> { template<int R> void test ();};您的代码:template<> // T is fixedtemplate<> // R is fixedvoid object<>::test<1>() // T is default int, R is 1{}等效于:template<> // T is fixedtemplate<> // R is fixedvoid object<int>::test<1>() // T is int, R is 1{}关于c++ - 双template <>语句,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7794207/ (adsbygoogle = window.adsbygoogle || []).push({});