Vincent.Penquerch at artworks.co.uk
Thu Apr 4 23:05:05 UTC 2002
> What I want is that if I write in the declaration of a method that it
> throws one or more exceptions, then all calls to this method must be
> peformed withing a try block.
I don't think this is possible, but I might be wrong.
A method does not have to do a catch if it just wants to propagage
the exception, which is valid (and one of the interests of using
To do it though, this function should have a throw() clause,
which means it can throw anything. However, this is not enforced,
as legacy C++ code can throw anything without having this clause,
so it is essentially useless (and dangerous) to rely on it, since
if it throws something that's not expected, your program terminates
(well, calls terminate, which you might have redefined :))
This is clearly a Bad Thing. Thus, for these two reasons, I don't
think you can have a C++ compiler that enforces callers of functions
that can throw using try/catch at calls.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the tuxCPProgramming