Exceptions and overridden methods

M

Milan Gornik

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
 
L

lilburne

Milan said:
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/resources/articles/lsp.pdf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top