编译器错误 C3380

“class”: 程序集访问说明符无效 - 只允许“public”或“private”

应用于托管类或结构时, publicprivate 关键字指示是否通过程序集元数据公开此类。 程序中使用 public /clr private 编译的类只可使用

refvalue 关键字与 /clr 一起使用时,指示该类受托管(请参阅类和结构)。

以下示例生成 C3380:

// C3380_2.cpp
// compile with: /clr
protected ref class A {   // C3380
// try the following line instead
// ref class A {
public:
   static int i = 9;
};

int main() {
   A^ myA = gcnew A;
   System::Console::WriteLine(myA->i);
}