Inheriting function template from super class

Alexey invalid at email.address
Mon Sep 27 14:54:41 UTC 2021


hello.
here I have some code sample.
I'm not sure if this is my incorrect code or incorrect dmd 
behavior.
Intention is C2 to inherit C1's `void writetext(alias A1)()` and 
instantiate it with `this.writetext!(typeof(this))();`
```D
import std.stdio;

class C1
{
     void writetext()
     {
         this.writetext!(typeof(this))();
     }

     void writetext(alias A1)()
     {
         writeln("C1 writetext(alias A1) ", this);
     }
}

class C2 : C1
{
     override void writetext()
     {
         // if line 21 is commented and line 22 is uncommented - 
this compiles ok
         this.writetext!(typeof(this))();
         // super.writetext!(typeof(this))();
     }
}

void main()
{
     auto c2 = new C2;
     c2.writetext();
}

```


More information about the Digitalmars-d-learn mailing list