delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/14/12:30:47

From: drwgrphcs AT aol DOT com (DrwGrphcs)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Undocumented Keyword...
Lines: 33
NNTP-Posting-Host: ladder05.news.aol.com
X-Admin: news AT aol DOT com
Date: 13 Apr 1999 16:47:04 GMT
Organization: AOL http://www.aol.com
References: <3711ACD9 DOT FFEE04F9 AT kampsax DOT dtu DOT dk>
Message-ID: <19990413124704.17462.00000053@ng20.aol.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019