Edit

Share via


Compiler Error C3379

'class' : a nested class cannot have an assembly access specifier as part of its declaration

When applied to a managed type, such as class or struct, the public and private keywords indicate whether the class will be exposed through assembly metadata. public or private cannot be applied to a nested class, which will inherit the assembly access of the enclosing class.

When used with /clr, the ref and value keywords indicate that a class is managed (see Classes and Structs).

The following sample generates C3379:

// C3379a.cpp
// compile with: /clr
using namespace System;

public ref class A {
public:
   static int i = 9;

   public ref class BA {   // C3379
   // try the following line instead
   // ref class BA {
   public:
      static int ii = 8;
   };
};

int main() {

   A^ myA = gcnew A;
   Console::WriteLine(myA->i);

   A::BA^ myBA = gcnew A::BA;
   Console::WriteLine(myBA->ii);
}