共用方式為


編譯器錯誤 C3380

'class' : 組件存取規範無效 - 只能使用 'public' 或 'private'

套用至 Managed 類別或結構時, publicprivate 關鍵字會指出類別是否將透過組件中繼資料公開。 只有 publicprivate 能夠套用至以 /clr所編譯程式中的類別。

和 關鍵詞與 /clr 搭配使用時,表示類別是受控的(請參閱類別和結構)。value ref

下列範例會產生 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);
}