By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

Exceptions and overridden methods

P: n/a


Hello guys,

I consulted both MSDN and Borland Builder's documentation to try to find
something about this, but I haven't found it. I saw that both VC++ and
Builder support different kinds of exception handling mechanisms. As I
understand, the standard way is to use exception handling through exception
classes and try/catch statements. Now, in Java, it is mandatory to supply
method prototype with info on which exceptions can occur. This seems to be
supported by Borland C++, and looks like a good way to have good, documented
code. Is it the part of ANSI C++ standard? Furthermore, I was in doubt what
to do if I have inherited class and want to override the parent's class
method. If I have method in base class which declares to throw some
exceptions, compiler would complain if exact set of exceptions were not
supplied by overriding method in derived class. I have situation in which I
would like to add some more possible exceptions in overridden method. Is it
possible, and should I really use this method of documenting possible
exceptions in methods?

Thanks in advance,

Milan Gornik


Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Milan Gornik wrote:
Hello guys,

I consulted both MSDN and Borland Builder's documentation to try to find
something about this, but I haven't found it. I saw that both VC++ and
Builder support different kinds of exception handling mechanisms. As I
understand, the standard way is to use exception handling through exception
classes and try/catch statements. Now, in Java, it is mandatory to supply
method prototype with info on which exceptions can occur. This seems to be
supported by Borland C++, and looks like a good way to have good, documented
code.
Don't use them:
http://www.gotw.ca/gotw/082.htm
Is it the part of ANSI C++ standard?
Yes.
Furthermore, I was in doubt what
to do if I have inherited class and want to override the parent's class
method. If I have method in base class which declares to throw some
exceptions, compiler would complain if exact set of exceptions were not
supplied by overriding method in derived class. I have situation in which I
would like to add some more possible exceptions in overridden method. Is it
possible, and should I really use this method of documenting possible
exceptions in methods?


Don't do that:
http://www.objectmentor.com/resource...les/lsp.pdf%20
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.