This documentation is archived and is not being maintained.

Restrictions of Managed Types

Visual Studio .NET 2003

Although managed types appear and behave much like unmanaged types, the common language runtime does impose some limitations.

GC and value types cannot:

  • Derive from unmanaged types.
  • Have unmanaged types derived from them.
  • Define custom copy constructors.
  • Declare friend members, classes, or interfaces. The concept of friend is not supported by the common language runtime.
  • Overwrite the new or delete operators.
  • Contain members that are const or volatile.
  • Contain pointers to other managed types (see Pointers).
  • Be used with run-time type information (RTTI).

GC types cannot:

  • Be instantiated globally or locally. They must be created on the managed heap with the new operator.
  • Derive from multiple base classes. (Multiple inheritance is not supported by the common language runtime. This restriction does not apply to the use of interface types as base classes.)
  • Override operator&.
  • Be destroyed with the delete operator unless a destructor is defined.
  • Use protected or private inheritance.
  • Be passed by value.

Value types cannot:

  • Be created directly on the managed heap. They can exist on the heap through embedding and boxing, however.
  • Have a base type (other than the implicit base class System::ValueType).
  • Define virtual functions (but can override those inherited from System::ValueType).
  • Be instantiated using the new operator (unless the unmanaged __nogc new operator is used.)

See Also

Managed Extensions for C++ Development Scenarios