編譯器錯誤 C3890
'var' :您無法取得常值數據成員的位址
垃圾收集堆積上有常值數據成員。 垃圾收集堆積上的物件可以移動,因此取得位址並無用處。
下列範例會產生 C3890:
// C3890.cpp
// compile with: /clr
ref struct Y1 {
literal int staticConst = 9;
};
int main() {
int p = &Y1::staticConst; // C3890
int p2 = Y1::staticConst; // OK
}