exception - STL C++

uncaught_exception()

Declaration

bool uncaught_exception();

Description

This is the function uncaught_exception() in the exception header. This function returns true after an exception is thrown, but not yet handled. Otherwise, it returns false.

Header Include

#include <exception>

Example

#include <iostream>
#include <exception>

class TestUncaught {
public:
	TestUncaught(int iIndex) : miIndex(iIndex) {}
	~TestUncaught() {
		using namespace std;
		cout << miIndex << ". uncaught_exception() returns = " <<
			uncaught_exception() << endl;
	}

	int miIndex;
};

int main() {

	TestUncaught qTestOut(1);
	try {
		TestUncaught qTestIn(2);
		// Just throw something
		throw "XoaX.net";
	} catch (...) {
	}

	return 0;
}

Output

uncaught_exception() Output
 

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