以下2种语法之间有什么区别:
template<int N> struct A; // (1)
Run Code Online (Sandbox Code Playgroud)
和
template<const int N> struct A; // (2)
Run Code Online (Sandbox Code Playgroud)
何时使用每种语法的一般准则?
const关键字在此模板中的作用是什么?
template <class T, int const ROWNUM, int const COLNUM>
class Matrix
Run Code Online (Sandbox Code Playgroud)
这是否意味着此模板仅接受constas参数?如果是这样,有没有办法将变量作为COLNUM和ROWNUM?
(当我尝试将变量作为模板的COLNUM传递时,它会出错:"IntelliSense:expression必须具有常量值")