exception - STL C++

unexpected()

Declaration

void unexpected();

Description

This is the function unexpected() in the exception header. This function is to be called when an unexpected exception is thrown and not caught.

Header Include

#include <exception>

Example

#include <iostream>
#include <exception>

void NewUnexpected() {
	std::cout << "Unexpected exception handler!" << std::endl;
	terminate();
}

int main() {
	// Set a new unexpected handler and get the old one back
	unexpected_handler qOldUnexpected = set_unexpected(NewUnexpected);

	// Call the unexpected function directly
	unexpected();

	return 0;
}

Output

unexpected() Output
 

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