Below there are two routines with the same name.
Apparently both can be present at the same time.

Which one of the two is the recommended code?



import std.stdio;

interface ITest
{
        int first();
        int second();
}

class Test: ITest
{
        int first()
        {
                writeln("first");
                return 1;
        }
        
        int second()
        {
                writeln("second");
                return 2;
        }
}

void routine(T:ITest) (T a)
{
        a.second();     
}

void routine(T) (T a) if (is(T:ITest))
{
        a.first();
}

int main()
{
        routine(new Test());
        return 0;
}


-----------------------
The above example prints out first.

Reply via email to