Ok, so if I remember correctly, typeid returns some sort of char or maybe it’s a string. For now I’ll just assume that’s correct. If a make a new 'type' with typedef, will it have a different return than the type that it’s covering?
1 2 3 4 5
// ok’d how to use typedef or typeid, so bear with me. I apologize for any
// mistakes in advance.
typedef xxT as int; // obviously not how it works but whatever.
std::cout << typeid(xxT) == typeid(int); // t or f?
The typedef specifier, when used in a declaration's decl-specifier-seq, […] declares typedef-names […] which is a synonym for the type of the object or function that it would become if the keyword typedef were removed.
[…]
The typedef-names are aliases for existing types, and are not declarations of new types. Typedef cannot be used to change the meaning of an existing type name (including a typedef-name). Once declared, a typedef-name may only be redeclared to refer to the same type again.
2) If you declare a new type, that doesn’t cover for any other type. It’s just a new type.
You can declare a new type for example by simply typing
class MyNewType {}; // here you are!
1 2
typedef xxT as int; // obviously not how it works but whatever.
std::cout << typeid(xxT) == typeid(int); // t or f?
Ehm… If you’ve already written the code, why don’t you simply try to execute it?
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include <typeinfo>
int main()
{
typedefint xxT;
// Personal preference: I find it more legible: using xxT = int;
std::cout << ( typeid(xxT) == typeid(int) ? "Bingo!" : ":-(" ) << '\n';
}