Automatic method overriding in sub-classes

Daniel N via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 31 02:04:51 PDT 2015


On Friday, 30 October 2015 at 21:38:40 UTC, bitwise wrote:
> On Thursday, 29 October 2015 at 01:14:35 UTC, Tofu Ninja wrote:
>> On Thursday, 29 October 2015 at 00:11:06 UTC, Tofu Ninja wrote:
>>> [...]
>>
>> Actually never mind, what I just said was basically auto 
>> override for this() so its not really any different. And it is 
>> kinda limited with some problems.
>

It's not without issues, but changing it to 'this(this T = 
void)()' makes it work(for one level of inheritance).

class Base
{
   string str;
   string function() fun;

   this(this T = void)()
   {
     str = T.stringof;
     fun = function() { return T.stringof;};
   }
}
class Child : Base {}


More information about the Digitalmars-d mailing list