小编tud*_*ion的帖子

::运算符在这种情况下会做什么

template <int N>
struct Factorial {
  static const int value = N * Factorial<N - 1>::value;
};

// Base case via template specialization:

template <>
struct Factorial<0> {
  static const int value = 1;
};
Run Code Online (Sandbox Code Playgroud)

因此,我可能已经发现,“ ::”运算符的作用是以某种方式将较早执行的操作的内容(N *阶乘)馈入/添加到“值”变量中。但是有人可以更彻底地解释这一点吗(我不介意对'::'运算符角色的完整解释)。

非常感谢你!

c++ templates static-methods template-meta-programming

3
推荐指数
2
解决办法
201
查看次数