home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 May
/
VPR9705A.ISO
/
VPR_DATA
/
PROGRAM
/
CBTRIAL
/
SETUP
/
DATA.Z
/
EXCEPTIO.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1997-02-14
|
775b
|
35 lines
#include <iostream.h>
#include <stdexcept>
using namespace std;
#ifdef RWSTD_NO_EXCEPTIONS
int main ()
{
cout << "Your compiler doesn't support exceptions!" << endl;
return 0;
}
#else
static void f() { throw runtime_error("a runtime error"); }
int main ()
{
//
// By wrapping the body of main in a try-catch block we can be
// assured that we'll catch all exceptions in the exception hierarchy.
// You can simply catch exception as is done below, or you can catch
// each of the exceptions in which you have an interest.
//
try
{
f();
}
catch (const exception& e)
{
cout << "Got an exception: " << e.what() << endl;
}
return 0;
}
#endif /*RWSTD_NO_EXCEPTIONS*/