Using XCode 3.2.3 (64-bit), I get following strange output. What am I doing wrong?
#include <iostream>
#include <typeinfo>
struct student {
};
int main()
{
int i;
student obj;
std::cout << typeid(i).name() << "\n";
std::cout << typeid(obj).name() << "\n";
return 0;
}
Output:
i
7student
What's going on is nothing special. Just that typeid
doesn't promise to return the "original" name of the type, but just a name.
The function returns an implementation-defined string, which, if you're lucky, is recognizable, but it makes no promise of that.