Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changes from Version 1 of RuntimeTypeInformationExample

Show
Ignore:
Author:
jcc7 (IP: 68.97.93.38)
Timestamp:
11/14/05 03:52:38 (16 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RuntimeTypeInformationExample

    v0 v1  
     1= Runtime Type Information (RTTI) = 
     2 
     3''Part of'' TutorialIntermediate 
     4 
     5== Description == 
     6 
     7You can find out some class information during runtime. 
     8 
     9== Example == 
     10 
     11{{{ 
     12#!d 
     13import std.c.stdio; 
     14 
     15class A {} 
     16 
     17int main ( char [] [] args )  
     18{ 
     19    A a = new A; 
     20    Object o; 
     21    o = new Object; 
     22    bit b; 
     23     
     24    printf("%.*s\n", a.classinfo.name); 
     25    printf("%.*s\n", o.classinfo.name); 
     26 
     27    /* These aren't allowed... */ 
     28 
     29//    printf("%.*s\n", b.classinfo.name); 
     30//    printf("%.*s\n", b.typeinfo.name); 
     31 
     32    return 1; 
     33} 
     34}}} 
     35 
     36== More Information == 
     37 
     38See also:  
     39 * http://www.prowiki.org/wiki4d/wiki.cgi?HowTo/RealtimeTypeInformation 
     40 * http://www.prowiki.org/wiki4d/wiki.cgi?FaqRoadmap#DoesDsupportanyformofRTTI 
     41 
     42 
     43== Source == 
     44 
     45|| Link || http://www.dsource.org/tutorials/index.php?show_example=34 || 
     46|| Posted by || jcc7 || 
     47|| Date/Time || Mon May 3, 2004 12:18 am ||