共用方式為


編譯器錯誤 C2971

'class' : 樣板參數 'param' : 'arg' : 局部變數不能當做非型別自變數使用

您無法使用局部變數的名稱或地址作為範本自變數。

下列範例會產生 C2971:

// C2971.cpp
template <int *pi>
class Y {};

int global_var = 0;

int main() {
   int local_var = 0;
   Y<&local_var> aY;   // C2971
   // try the following line instead
   // Y<&global_var> aY;
}