April 2002
Intermediate to advanced
1024 pages
23h 26m
English
Handling managed exceptions in VC++ is basically the same as C#. VC++ using managed extensions exposes some features of exceptions that are not available in C#. Those differences will be illustrated later. Listing 15.12 shows how to define and use a custom exception class. The full source for this sample can be found in C++Exceptions\BasicExceptions.
__gc class MyException : public System::ApplicationException
{
public:
MyException() : System::ApplicationException()
{
}
MyException(System::String __gc *msg) : System::ApplicationException(msg)
{
}
} ;
void ThrowMyException()
{
throw new MyException(new System::String("This exception is thrown from
ThrowMyException")); } int wmain(void) ... |
Read now
Unlock full access