首页 > 试题广场 >

以下模板元编程代码在编译期计算阶乘,结果是什么?```cpp

[单选题]
以下模板元编程代码在编译期计算阶乘,结果是什么?
template<int N>
struct Factorial {
static constexpr int value = N * Factorial<N-1>::value;
};
template<>
struct Factorial<0> {
static constexpr int value = 1;
};
static_assert(Factorial<5>::value == ?);
  • 60
  • 120
  • 24
  • 720

这道题你会答吗?花几分钟告诉大家答案吧!