typeid() woes
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sun Aug 8 15:25:26 PDT 2010
Thanks, that works.
On Mon, Aug 9, 2010 at 12:21 AM, Adam Ruppe <destructionator at gmail.com>wrote:
> On 8/8/10, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> > I wonder if there's a way to get the static type, is there an equivalent
> > function like typeid() for such a case?
>
> Try this:
>
> typeid(typeof( X ));
>
> typeof() returns the static type of the variable. Then, you can get
> the typeid of that returned static type.
>
> Here's a sample program:
> ====
> import std.stdio;
> class Something { }
> class SomethingElse : Something {}
>
> void main() {
> Something o = new SomethingElse;
> writeln(typeid(typeof(o)));
> }
> ====
> Prints: test6.Something
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100809/11ad2d5e/attachment-0001.html>
More information about the Digitalmars-d
mailing list