Re: throwing CException
- From: "Abdo Haji-Ali" <ahali@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 11 Sep 2005 11:40:45 +0300
Is this OK:
> try {
> callSomeFunc();
> } catch (CException &e) {
> char msg[999];
> e.GetErrorMessage(msg, sizeof(msg));
> AfxMessageBox(msg);
> return;
> }
No.
> or I _have_ to use "CException *e"?
When you used the throw statement you used the new statement to create an
instance of the class on the heap, which returned a pointer to that
instance; and that pointer was "associated" with the exception... So
catching the exception sould match the associated data (in your case the
pointer to CMyException, or its parent for that matter)
> Also, do I have to call e->Delete() and when?
As I said you created the class instance on the heap, so you HAVE to delete
it (Unless you want to see some memory leaks), and of course the deletion of
a pointer (allocated on the heap) should happen when you're done with it,
apparently :)
Abdo Haji-Ali
Programmer
In|Framez
.
- References:
- throwing CException
- From: Petar Popara
- throwing CException
- Prev by Date: Re: MessageBox buttons
- Next by Date: Re: VS 7.1 IDE bug w/ Events
- Previous by thread: throwing CException
- Next by thread: Re: throwing CException
- Index(es):