exception - STL C++

terminate()

Declaration

void terminate();

Description

This is the function terminate() in the exception header. This function calls the termination handler that is called when the program terminates.

Header Include

#include <exception>

Example

#include <iostream>
#include <exception>

void NewTerminate() {
	std::cout << "The end." << std::endl;
	abort();
}

int main() {
	// Set a new terminate handler and get the old one back
	terminate_handler qOldTerminate = set_terminate(NewTerminate);

	// Call terminate directly
	terminate();

	return 0;
}

Output

terminate() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.