John Carson said:
This is implementation-specific. According to Stroustrup (TC++PL, p. 381),
"In principle, exception handling can be implemented so that there is no
run-time overhead when no exception is thrown." However, it is known, for
example, that VC++ exception handling does have a run-time cost even when no
exception is thrown. This cost is only small so can be ignored for most
purposes.
Any cost may also be less than the traditional alternative of checking the
return value of every function call. That obviously has a run time cost, but
even more importantly leads to great difficulties in code maintenance. I've
seen many, many examples of code which is trying to catch rarely occurring
errors in a deeply nested series of function calls, but where the code
doesn't work correctly in the face of errors, inevitably because some return
values aren't checked.
john