Exception Handling, Scope and Destructor questions

orgoton orgoton at mindless.com
Mon Feb 12 10:43:46 PST 2007

The D specification says that when an object is destroyer (either implicitly or by GC action) the destructors of al inherited classes are also called. However, if I have a class "one" and a class "two", which inherits from class "one", if I call any instance of "two", the destructor of "one" also gets called. The question is: if I use a reference to "two" in form of "one", will the destructor of "two" be called?

ONE handle=new TWO;
delete handle;

Next question:
I have a try block which may have one of several exceptions thrown, and depending on which, I call a different catch:

catch(ExceptionType1 e)
catch(ExceptionType2 e)
process 2;
catch(Exception e)

Since ExceptionType1 and Type2 both inherit from call Exception, does the last catch execute along with Type1 or Type2?
Please confirm, the finally{} block ALWAYS gets called, right?

Lastly, the catch() does not need to have a scope, yes? something like catch(Exception e) ProcessGeneric(); in summary of the code above?

More information about the Digitalmars-d-learn mailing list