typeid, typeinfo, classinfo not returning most derived

Adam D. Ruppe destructionator at gmail.com
Thu Jun 6 20:34:05 UTC 2019


On Thursday, 6 June 2019 at 20:22:00 UTC, Amex wrote:
> I i = new D();

It is a bizarre quirk, I think because interfaces do not 
necessarily point to objects with RTTI (though this can be 
statically determined, so I am not sure that is valid), but when 
you do typeid on an interface, it gives the typeinfo for that 
interface, not the object itself.

First cast to Object, then get the typeid and you'll see what you 
want to see.

maybe we should just change this behavior.


More information about the Digitalmars-d-learn mailing list