<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2448.0">
<TITLE>RE: [LC++]check throws</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>&gt; What I want is that if I write in the declaration of a method that it </FONT>
<BR><FONT SIZE=2>&gt; throws one or more exceptions, then all calls to this method must be </FONT>
<BR><FONT SIZE=2>&gt; peformed withing a try block.</FONT>
</P>

<P><FONT SIZE=2>I don't think this is possible, but I might be wrong.</FONT>
<BR><FONT SIZE=2>A method does not have to do a catch if it just wants to propagage</FONT>
<BR><FONT SIZE=2>the exception, which is valid (and one of the interests of using</FONT>
<BR><FONT SIZE=2>exceptions).</FONT>
<BR><FONT SIZE=2>To do it though, this function should have a throw() clause,</FONT>
<BR><FONT SIZE=2>which means it can throw anything. However, this is not enforced,</FONT>
<BR><FONT SIZE=2>as legacy C++ code can throw anything without having this clause,</FONT>
<BR><FONT SIZE=2>so it is essentially useless (and dangerous) to rely on it, since</FONT>
<BR><FONT SIZE=2>if it throws something that's not expected, your program terminates</FONT>
<BR><FONT SIZE=2>(well, calls terminate, which you might have redefined :))</FONT>
<BR><FONT SIZE=2>This is clearly a Bad Thing. Thus, for these two reasons, I don't</FONT>
<BR><FONT SIZE=2>think you can have a C++ compiler that enforces callers of functions</FONT>
<BR><FONT SIZE=2>that can throw using try/catch at calls.</FONT>
</P>

<P><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Vincent Penquerc'h </FONT>
</P>

</BODY>
</HTML>