编译器错误 C3900
“member”:不允许在当前范围内使用
属性块只能包含函数声明和内联函数定义。 属性块中不允许除函数以外的成员。 不允许使用 typedefs、运算符或友元函数。 有关详细信息,请参阅 property。
事件定义只能包含访问方法和函数。
以下示例生成 C3900:
// C3900.cpp
// compile with: /clr
ref class X {
property int P {
void set(int); // OK
int i; // C3900 variable declaration
};
};
以下示例生成 C3900:
// C3900b.cpp
// compile with: /clr
using namespace System;
delegate void H();
ref class X {
event H^ E {
int m; // C3900
// OK
void Test() {}
void add( H^ h ) {}
void remove( H^ h ) {}
void raise( ) {}
}
};