Displaying type of something

Georg Wrede georg.wrede at iki.fi
Mon Mar 9 12:06:27 PDT 2009


bearophile wrote:
> Georg Wrede:
>> When creating templates, it is sometimes handy to print the type of 
>> something. Is there a trivial way to print it?
> 
> writeln("Typeof T is: ", typeid(typeof(t)));
> 
> (Try alternatives of that with a dynamic type, like a class).

Thanks!!!


     class A { }
     class B : A { }
     class C : B { }
     A a;
     B b;
     C c;
     A ac = new C;

Typeof ac is: A

So it's the variable, not its current contents. Kinda makes sense.


More information about the Digitalmars-d-learn mailing list