delegate bug?

Jack Applegame japplegame at gmail.com
Fri Nov 9 05:36:46 PST 2012


This code:

import std.stdio;
class A {
   void func() { writeln("A"); }
}
class B : A {
   override void func() { writeln("B"); }
}
void main() {
   A a = new A;
   B b = new B;

   auto dg = &a.func;
   dg();

   dg.ptr = cast(void*)b;
   dg();
}

outputs:
A
A

but expected:
A
B


More information about the Digitalmars-d-learn mailing list