編譯器錯誤 C3137
'property' :無法初始化屬性
例如,在建構函式的初始化清單中,無法初始化屬性。
下列範例會產生 C3137:
// C3137.cpp
// compile with: /clr /c
ref class CMyClass {
public:
property int Size {
int get() {
return 0;
}
void set( int i ) {}
}
CMyClass() : Size( 1 ) { // C3137
// to resolve this C3137, remove the initializer from the
// ctor declaration and perform the assignment as follows
// Size = 1;
}
};