为了处理构造函数初始化列表中抛出的异常,应该将构造函数编写为函数测试块(function try block),将一组catch子句与函数联成一个整体。 如果局部动态分配了内存,而在释放内存前抛出了异常,则局部内存将无法正确释放。
基于66个网页-相关网页
The only way for a constructor to handle an exception from a constructor initializer is to write the constructor as a function try block.
构造函数要处理来自构造函数初始化式的异常,唯一的方法是将构造函数编写为函数测试块。
SafeHandleRequest calls the function that is the second argument inside a try and except block.
_ safeHandleRequest调用的函数是try和except块内部的第二个参数。
应用推荐