Re: Unmanaged exception caught how in managed code?
From: Hendrik Schober (SpamTrap_at_gmx.de)
Date: 02/09/04
- Next message: Hendrik Schober: "Re: Trouble displaying MessageBox from VC++ form"
- Previous message: Hendrik Schober: "Re: array of pointers to class methods"
- In reply to: Yan-Hong Huang[MSFT]: "Re: Unmanaged exception caught how in managed code?"
- Next in thread: Yan-Hong Huang[MSFT]: "Re: Unmanaged exception caught how in managed code?"
- Reply: Yan-Hong Huang[MSFT]: "Re: Unmanaged exception caught how in managed code?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 9 Feb 2004 10:44:43 +0100
Mhmm. While catching by reference certainly
is better than catching by value (beeing
who I am I mostly catch by const reference),
actually I was refereing to your
throw new S()
as this begs the question of who will be
responsible for deleting the object.
Schobi
Yan-Hong Huang[MSFT] <yhhuang@online.microsoft.com> wrote:
> Hi Schobi,
>
> You are correct. This is just extracted from some sample code. throw S()
> --> catch (S& s) is better.
>
> While the Standard doesn't specify where the exception object in catch (xc
> & x) is stored, most implementation maintain a special exception stack, on
> which exception are constructed (however, the Standard does not allow the
> implementation to use free store memory for that purpose). Passing an
> exception by reference is preferred to passing an exception by value for
> several reasons: as you suggested, it short circuits the process of passing
> the exception object to its handler (only a reference is copied rather than
> a full-blown object). However, pass by reference also ensures that derived
> exceptions are not sliced. Finally, it enables you to modify the exception
> and then pass it on to another handler (i.e., a re-throw) with the changes
> made to that object.
>
> Thanks for pointing it out. :)
>
> Best regards,
> Yanhong Huang
> Microsoft Community Support
>
> Get Secure! ¨C www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no rights.
-- SpamTrap@gmx.de is never read I'm Schobi at suespammers dot org "Sometimes compilers are so much more reasonable than people." Scott Meyers
- Next message: Hendrik Schober: "Re: Trouble displaying MessageBox from VC++ form"
- Previous message: Hendrik Schober: "Re: array of pointers to class methods"
- In reply to: Yan-Hong Huang[MSFT]: "Re: Unmanaged exception caught how in managed code?"
- Next in thread: Yan-Hong Huang[MSFT]: "Re: Unmanaged exception caught how in managed code?"
- Reply: Yan-Hong Huang[MSFT]: "Re: Unmanaged exception caught how in managed code?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|