#include "iostream"
#include "conio.h"
#include "exception"
#include "cstdlib"
using namespace std;
void myunexpected()
{
cerr << "unexpected called\n";
throw 0; // throws int (in exception-specification)
}
void myfunction() throw (int)
{
throw 'x'; // throws char (not in exception-specification)
}
int main (void)
{
set_unexpected (myunexpected);
try
{
myfunction();
}
catch (int) { cerr << "caught int\n"; }
catch (...) { cerr << "caught other exception (non-compliant compiler?)\n"; }
getch();
return 0;
}
ausgeführtAusgabe aufrufen (Wenn auf Visual Studio 2008 ausgeführt): andere Ausnahme gefangenException Handling - set_unexpected() nicht in der Lage
Aber ich erwartete (nicht konforme Compiler?) der Ausgang zu sein:
genannt unerwartete
gefangen int
HINWEIS: Ich habe dieses Programm auf Visual Studio 2008.
Danke Man: -): D ;-) – Jatin