menu

hjk41的日志

Avatar

More Effective C++ 11: Prevent exceptions from leaving destructors

Destructors are called in two situations, normal and abnormal. The normal situation is when an object goes out of scope, or when it is explicitly deleted. The abnormal situation is when an exception is thrown. And if an exception arises during the existance of another, C++ will terminate your program immediately.
So we better prevent exceptions from leaving destructors if we don't want our program to be terminated that way. The only way to do that is using try and catch. However, sometimes the catch block gives rise to exceptions itself, in which case we should do nothing in the catch block.

评论已关闭