Is it possible to return the subclass from a method of the parent class in dlang?

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Mar 3 00:22:02 UTC 2018


On Sat, Mar 03, 2018 at 01:13:43AM +0100, Christian Köstlin via Digitalmars-d-learn wrote:
> >> class Timer : Thread {
> >>    override Timer start() { ... }
> >> }
> >>
> >> https://dlang.org/spec/function.html#virtual-functions
> >>
> >> (see item 6)
> >>
> >> -Steve
> > Thanks for this.
> > It works for me only without the override (with override I get
> > Error: function timer.Timer.start does not override any function,
> > did you mean to override 'core.thread.Thread.start'?).
>
> This seems to be connected to Thread.start being a final function.

Well, yes, you cannot override a final function.  That is the point of
`final`. :-D

If you meant to override it after all, remove the `final`.


T

-- 
Life is complex. It consists of real and imaginary parts. -- YHL


More information about the Digitalmars-d-learn mailing list