Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C3830

'type1': cannot inherit from 'type2', value types can only inherit from interface classes

A value type cannot inherit a base class. For more information, see Classes and Structs (Managed).

The following sample generates C3830:

// C3830a.cpp
// compile with: /clr /c
public value struct MyStruct4 {
   int i;

public value class MyClass : public MyStruct4 {};   // C3830

// OK
public interface struct MyInterface4 {
   void i();

public value class MyClass2 : public MyInterface4 {
   virtual void i(){}

Managed Extensions for C++

A __value type cannot inherit a base class.

The following sample generates C3830:

// C3830b.cpp
// compile with: /clr:oldSyntax /c
#using <mscorlib.dll>
__value struct v : public System::Object {};   // C3830
__value struct w {};   // OK

Community Additions

© 2015 Microsoft