Template method overloading

Dominic Letz dominic.letz at berlin.de
Tue Jan 23 09:01:50 PST 2007


Hello, 

I'm trying to overload a template method. But it seems not to produce the expected result, although everything is compiling fine.

My sample is this: (Compiled with win32 dmd version 1.0). I expect:
A is called with 1
B is called with 2
But I got this:
A is called with 1
A is called with 2

the file:
import std.stdio;
class A
{
    void someMethod(T)(T i)
    {
        writefln("A is called with %d", i);
    }
}
class B : A
{
    void someMethod(T)(T i)
    {
        writefln("B is called with %d", i);
    }
}
int main()
{
    A test = new A();
    test.someMethod(1);
    test = new B();
    test.someMethod(2); 
    return 0;
}




More information about the Digitalmars-d mailing list