软讯网络 > 编程语言 > C/C++ > 编程交流与学习--More Effective C++的学习-Item M11:禁止异常信息(exceptions)传递到析构函数外
【标 题】:编程交流与学习--More Effective C++的学习-Item M11:禁止异常信息(exceptions)传递到析构函数外
【关键字】:
--More,Effective,C++,-Item,M11,exceptions
【来 源】:http://blog.csdn.net/swordll80/archive/2006/09/24/1273141.aspx
编程交流与学习--More Effective C++的学习-Item M11:禁止异常信息(exceptions)传递到析构函数外
原因:“第一能够在异常转递的堆栈辗转开解(stack-unwinding)的过程中,防止terminate被调用。第二它能帮助确保析构函数总能完成我们希望它做的所有事情。”
解决方法:
Session::~Session()
{
try {
logDestruction(this);
}
catch (...) { }
}