共用方式為


編譯器錯誤 C3887

'var' :常值數據成員的初始化運算式必須是常數表達式

備註

常值數據成員只能使用常數 expresion 初始化。

Example

下列範例會產生 C3887:

// C3887.cpp
// compile with: /clr
ref struct Y1 {
   static int i = 9;
   literal
   int staticConst = i;   // C3887
};

可能的解決方式:

// C3887b.cpp
// compile with: /clr /c
ref struct Y1 {
   literal
   int staticConst = 9;
};