template <unsigned int n>
struct D {
enum { value = n * D<n - 1>::value };
};
template <>
struct D<0> {
enum { value = 1 };
};
计算阶乘的模板递归,使用:
D<10>;
D<100>;
template <unsigned int n>
struct D {
enum { value = n * D<n - 1>::value };
};
template <>
struct D<0> {
enum { value = 1 };
};
计算阶乘的模板递归,使用:
D<10>;
D<100>;