The typeid
represents a C++ RTTI operator being also a C++ keyword. It returns a std::type_info
object that holds (dynamic) type specific information.
From what I understood from various sources, one MUST include <typeinfo>
when using typeid
, otherwise the program is ill-formed. In fact, my gcc5.2 compiler doesn't even compile the program if I don't include the before-mentioned header. I don't understand why is a header inclusion mandated for the usage of a C++ keyword. I understand mandating a header for whenever we use some object declared/defined in that header, but typeid
is not of a class type. So what is the reason behind this enforcement of including the header <typeinfo>
?
If something is a requirement in order to do something else, then you use 'need to'. If it is something you are obligated to do regardless of any further goals, then you use 'have to'.
“Why do I need this” is a question of the present, it is current, therefore a question of what I need to understand now, the present tense. “Why did I need this” is a question of what has happened previously, in the past; something that has already accurred, so is past tense.
Two verbs in English Notice that the first verbs above(want, need) use the infinitive form for the second verb(to go, to bring). For this reason, we use “need to” and not “need too”.
The verbs need, have to, and must are all synonyms of one another and are used to mean that something is necessary or required.
The next paragraph:
The typeid expression is lvalue expression which refers to an object with static storage duration, of the polymorphic type const std::type_info or of some type derived from it.
Because it is an lvalue expression, which uses reference initialization to declare an initializer of std::type_info
. <typeinfo>
contains the definition for that object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With