1

Possible Duplicate:
catch exception by pointer in C++

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

Community
  • 1
  • 1
jasonline
  • 8,646
  • 19
  • 59
  • 80

4 Answers4

2

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

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
2

By const reference. You can avoid object copying.

cx0der
  • 432
  • 5
  • 20
0

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

Yogesh Arora
  • 2,216
  • 2
  • 25
  • 35
0

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

rlbond
  • 65,341
  • 56
  • 178
  • 228