This documentation is archived and is not being maintained.

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 via 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 following keywords indicate that a class is managed:

The following sample generates C3379:

// C3379.cpp
// compile with: /clr
#using <mscorlib.dll>

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

   public __gc class BA {   // C3379. Remove public keyword.
   public:
      static int ii = 8;
   };
};

int main() {

   A *myA = new A;
   Console::WriteLine(myA->i);

   A::BA *myBA = new A::BA;
   Console::WriteLine(myBA->ii);
}
Show: