编译器错误 C3804
“property_accessor”:属性的访问器方法必须是全部静态或全部非静态的
定义关键属性时,访问器函数可以是静态的,也可以是实例,但不能两者都是。
有关更多信息,请参见 property 。
示例
下面的示例生成 C3804。
// C3804.cpp
// compile with: /c /clr
ref struct A {
property int i {
static int get() {}
void set(int i) {}
} // C3804 error
// OK
property int j {
int get() { return 0; }
void set(int i) {}
}
property int k {
static int get() { return 0; }
static void set(int i) {}
}
};