Like getClass()
Sergey Gromov
snake.scaly at gmail.com
Sat Sep 27 09:55:18 PDT 2008
Sat, 27 Sep 2008 12:15:07 -0400,
bearophile wrote:
> // D code
> import std.stdio;
> interface FooBar {}
> class Foo : FooBar {}
> class Bar : FooBar {}
> void main() {
> FooBar[] things;
> things ~= new Bar;
> things ~= new Foo;
> foreach (thing; things)
> writefln(typeid(typeof(thing)));
> }
> /*
> Output of the D version:
> test.FooBar
> test.FooBar
> */
typeof() gives a static type of an object. But I was sure that
thing.classinfo.name should have referred to the dynamic type name.
Apparently it's not the case, it prints the same test.FooBar as in your
test.
More information about the Digitalmars-d-learn
mailing list