打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
set-terminate

set_terminate

function
<exception>
terminate_handler set_terminate (terminate_handler f) throw();

Set terminate handler function

Sets f as the terminate handler function.

A terminate handler function is a function automatically called when the exception handling process has to be abandoned for some reason. This happens when a handler cannot be found for a thrown exception, or for some other exceptional circumstance that makes impossible to continue the handling process.

The terminate handler by default calls cstdlib's abort function.

Parameters

f
Function that takes no parameters and returns void.
The function shall not return and shall terminate the program.
terminate_handler is a function pointer type taking no parameters and returning void.

Return value

The current terminate handler function.
terminate_handler is a function pointer type taking no parameters and returning void.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// set_terminate example#include <iostream>#include <exception>#include <cstdlib>using namespace std;void myterminate () {  cerr << "terminate handler called\n";  abort();  // forces abnormal termination}int main (void) {  set_terminate (myterminate);  throw 0;  // unhandled exception: calls terminate handler  return 0;}


Possible output:
terminate handler calledAborted

See also

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Understanding setjmp/longjmp
一些简单的错误处理函数(二)
请问DELPHI调用约定中的问题?stdcall,safecall……都是什么意思?
A Crash Course on theDepths of Win32 Structured Exception Handling, MSJ January 1997
如何找到ABAP里被动态调用的update function module
exit(0),return 0有什么区别呢?
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服