32 template<typename A
, typename B
, typename C
>
34 rtti_test(A
*a
, const char *inputClass
, const char *classNameA
,
35 const char *classNameB
, const char *classNameC
)
37 printf("class %s\n", inputClass
);
38 printf(" dynamic_cast<%s*>(a): %p\n", classNameA
, dynamic_cast<A
*>(a
));
39 printf(" dynamic_cast<%s*>(a): %p\n", classNameB
, dynamic_cast<B
*>(a
));
40 printf(" dynamic_cast<%s*>(a): %p\n", classNameC
, dynamic_cast<C
*>(a
));
41 const std::type_info
*info
= &typeid(*a
);
42 printf(" typeinfo: %p, name: %s\n", info
, (info
? info
->name() : NULL
));
48 // test with artificial classes defined in this file
50 #define RTTI_TEST(obj, className) rtti_test<A, B, C>(obj, className, \
57 printf("A: %p (vtable: %p)\n", &a
, *(void**)&a
);
58 printf("B: %p (vtable: %p)\n", &b
, *(void**)&b
);
59 printf("C: %p (vtable: %p)\n", &c
, *(void**)&c
);
66 // test with real classes defined in a library
69 #define RTTI_TEST(obj, className) rtti_test<BNode, BFile, BDirectory>(obj, \
70 className, "BNode", "BFile", "BDirectory")
76 printf("BNode: %p (vtable: %p)\n", &node
, *(void**)&node
);
77 printf("BFile: %p (vtable: %p)\n", &file
, *(void**)&file
);
78 printf("BDirectory: %p (vtable: %p)\n", &dir
, *(void**)&dir
);
80 RTTI_TEST(&node
, "BNode");
81 RTTI_TEST(&file
, "BFile");
82 RTTI_TEST(&dir
, "BDirectory");