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

2018-03-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-02 21:23, Christian Köstlin wrote: To give an example: class Thread { ... Thread start() {...} } class Timer : Thread { ... } void main() { // Timer timer = new Timer().start; // this does not work auto timer = new Timer().start; // because timer is of type Thread

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

2018-03-02 Thread H. S. Teoh via Digitalmars-d-learn
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

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

2018-03-02 Thread Christian Köstlin via Digitalmars-d-learn
>> 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

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

2018-03-02 Thread Christian Köstlin via Digitalmars-d-learn
On 02.03.18 21:39, Steven Schveighoffer wrote: > On 3/2/18 3:23 PM, Christian Köstlin wrote: >> To give an example: >> >> class Thread { >>    ... >>    Thread start() {...} >> } >> >> class Timer : Thread { >>    ... >> } >> >> >> void main() { >>    // Timer timer = new Timer().start;  // this

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

2018-03-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/2/18 3:23 PM, Christian Köstlin wrote: To give an example: class Thread { ... Thread start() {...} } class Timer : Thread { ... } void main() { // Timer timer = new Timer().start; // this does not work auto timer = new Timer().start; // because timer is of type Thread }

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

2018-03-02 Thread Christian Köstlin via Digitalmars-d-learn
To give an example: class Thread { ... Thread start() {...} } class Timer : Thread { ... } void main() { // Timer timer = new Timer().start; // this does not work auto timer = new Timer().start; // because timer is of type Thread } thanks in advance, christian