aliasing superclass constructors
Nick Treleaven
ntrel-public at yahoo.co.uk
Wed Dec 26 09:11:27 PST 2012
On 26/12/2012 15:13, Maxim Fomin wrote:
> The problem is that Exception class ctor requires at least one explicit
> argument
> (https://github.com/D-Programming-Language/druntime/blob/master/src/object.di#L339).
>
>
> To solve the problem in general case you can either supply default
> arguments for all ctor parameters or define parameter-less ctor.
>
> In your particular case because you cannot change Exception you can
> inherit not from Exception class but from intermediate one, which does
> one of the mentioned things:
>
> import std.stdio;
>
> class DException : Exception
> {
> this(string value = "") { super(value); }
> }
Thanks for the reply. But actually I'm not looking to define a
parameter-less ctor for Exception subclasses, but to copy all of a
parent class's constructors into a subclass. This is nice to do for
Exception subclasses because sometimes I just want a new type that
behaves exactly the same, but has different RTTI. But for other classes
it can be useful if you want to override some methods, but don't need to
add/change any constructors, apart from exposing them from the parent.
I've found a relevant discussion:
http://forum.dlang.org/post/op.u36pc3y4o7cclz@korden-pc
More information about the Digitalmars-d-learn
mailing list