Question: how rtti works in c++?
Answer: In C++ the RTTI is a mechanism, that exposes information about an object's datatype during runtime. This feature can be available only when the class has at least one virtual function. It allows the type of an object to be determined when the program is executing. In the following example, the first code will not work.