开发者

Catching exceptions by value, reference or pointer [duplicate]

开发者 https://www.devze.com 2022-12-16 16:26 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: catch exception by pointer i开发者_运维技巧n C++
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

catch exception by pointer i开发者_运维技巧n C++

What is the best way to catch an exception: by value, reference or pointer and why?


You nearly always want to catch exceptions by (usually const) reference.


By const reference. You can avoid object copying.


You dont want to raise any more exceptions so catching by reference is best


By reference, unless you're doing Windows programming, where exceptions are typically caught by pointer.

0

精彩评论

暂无评论...
验证码 换一张
取 消