Beware of throwing exceptions from a destructor
The most plausible way to report a failure during object construction is by throwing an exception. However, this is not recommended for destructors. The problem is that a destructor may be invoked automatically when an uncaught exception is thrown in its scope. If the called destructor invoked due to an exception also throws an exception, the result is an infinite recursion.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.