Delphi programming blog


Run-time type identification (RTTI) lets you write portable code that can determine the actual type of a data object at run time even when the code has access only to a pointer or reference to that object. This makes it possible, for example, to convert a pointer to a virtual base class into a pointer to the derived type of the actual object. Use the dynamic_cast operator to make run-time casts. The RTTI mechanism also lets you check whether an object is of some particular type and whether two objects are of the same type. You can do this with typeid operator, which determines the actual type of its argument and returns a reference to an object of type const type_info, which describes that type. You can also use a type name as the argument to typeid, and typeid will return a reference to a const type_info object for that type. The class type_info provides an operator== and an operator!= that you can use to determine whether two objects are of the same type. Class type_info also provides a member function name that returns a pointer to a character string that holds the name of the type.

Статьи по теме:

1. Практическое использование RTTI-атрибутов (RTTI #10) 25.05.2013 г.
2. О глобальных переменных и RTTI#9 18.05.2012 г.
3. Цепочки событий (Event Chain) RTTI#8 19.02.2012 г.
4. Настройки программы в INI с использованием RTTI#7 27.01.2012 г.
5. Заметка о RTTI, TValue и real/double/extended 24.01.2012 г.
6. Экспорт бинарной записи в XML (RTTI#6) 27.11.2011 г.
7. Установка свойства для нескольких объектов (RTTI#5) 31.10.2011 г.
8. RTTI#4 30.07.2011 г.
9. RTTI #3 22.07.2011 г.
10. Изучая RTTI#2 18.04.2011 г.
11. Изучая RTTI #1 17.04.2011 г.