The typeid Operator
The "typeid" operator in RCVTB is only supported for use with variables of primitive types and non-abstract ( concrete ) classes. (See list 11)
* List 11 : Code not supported by RVCTB class base { public: virtual ~base(void) {} }; class derived : public base { }; int main(void) { base* p = new derived; printf("%s\n", typeid(*p).name()); delete p; return 0; }
To get the type information of an abstract class, use either a variable in the base class that retains type information, or a virtual function that returns it. ( List 12, 13 )
* List 12 :Code with variable in base class class base { private: int _typeid; protected: base(int id); public: int get_typeid(void) const; }; class derived_a : public base { public: derived_a(void); }; class derived_b : public base { public: derived_b(void); }; base::base(int id) : _typeid(id) { return; } int base::get_typeid(void) const { return _typeid; } derived_a::derived_a(void) : base(0x0000000A) { return; } derived_b::derived_b(void) : base(0x0000000B) { return; }
* List 13 : Code with virtual function class base { public: virtual int get_typeid(void) const = NULL; }; class derived_a : public base { public: virtual int get_typeid(void) const; }; class derived_b : public base { public: virtual int get_typeid(void) const; }; int derived_a::get_typeid(void) const { return 0x0000000A; } int derived_b::get_typeid(void) const { return 0x0000000B; }
Other
RVCTB does not support complex templates and name spaces.