Mail Archives: djgpp/1999/04/14/12:30:47
The try ... catch clauses are amazing. You can do all kinds of potentially
volatile stuff inside of a try, and if it blows up all over the place, you can
put alternate nice code in the catch.
The syntax looks like this
try{
variable / 0;
}catch(Exception e){
variable / 1
}
As you know, you cannot divide by zero, so that would automatically throw a
major exception, but the catch would catch that exception, and redirect it into
non volatile code.
I am not quite sure, but I think C++ also supports a finally statement as well.
This finally statement would take action after the try...catch. SO you would
have
try{
do dangerous
}
catch(Exception e){
do not so dangerous
}
finally{
make sure variables are appropriate before continuing on
}
No try can be alone without a catch, but you do not necessarily need a finally
clause. (I am not even sure C++ supports them).
Grace To You,
AK
- Raw text -