Export (0) Print
Expand All

14.1 throw

Visual Studio .NET 2003

The C++ throw expression is extended to throw a pointer to a __gc class.

Example

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

__gc struct G : System::Exception { int i; };

void f() {
   G * pG = new G;
   throw pG;
}

It follows that a value class can only be thrown when boxed.

Show:
© 2014 Microsoft