Template functions inside interface

Zans lllllll at mail.com
Tue Aug 4 13:36:15 UTC 2020


Is there any way to declare template functions inside interface 
and then override them in a class?
Trying to compile the following code results in "undefined 
reference" error:

import std.stdio;

interface MyInterface
{
     T doAndReturnSomething(T)(T param);
}

class MyClass : MyInterface
{
     override T doAndReturnSomething(T)(T param)
     {
         return param;
     }
}

void main()
{
     MyInterface myClass = new MyClass();
     writeln(myClass.doAndReturnSomething!(string)("Hello"));
}

Thanks in advance!


More information about the Digitalmars-d-learn mailing list