为了处理构造函数初始化列表中抛出的异常,应该将构造函数编写为函数测试块(function try block),将一组catch子句与函数联成一个整体。 如果局部动态分配了内存,而在释放内存前抛出了异常,则局部内存将无法正确释放。
基于64个网页-相关网页
函数测试块
Function test block
以上为机器翻译结果,长、整句建议使用 人工翻译 。
构造函数要处理来自构造函数初始化式的异常,唯一的方法是将构造函数编写为函数测试块。
The only way for a constructor to handle an exception from a constructor initializer is to write the constructor as a function try block.
youdao
应用推荐
模块上移
模块下移
不移动