Overriding Template Methods

Daniel L. Alves daniel_lopes_alves at hotmail.com
Sun Jan 29 18:23:05 PST 2012


Hi,
I don't know if this is a bug or if I'm doing something wrong, but I'm not
being able to override template methods. This can be seen with this simple code:

class Base
{
    void writeValueType( T )( T value )
    {
        writefln( "This is Base.writeValueType: value %s has type %s", value,
typeid( value ) );
    }
}

class Derived : Base
{
    override void writeValueType( T )( T value )
    {
        writefln( "This is Derived.writeValueType: value %s has type %s",
value, typeid( value ) );
    }
}

void main()
{
    Base b = new Derived();
    b.writeValueType( true );
}

The output should be:

This is Derived.writeValueType: value true has type bool

But, instead, it is:

This is Base.writeValueType: value true has type bool

Am I missing something?


More information about the Digitalmars-d-learn mailing list