为什么当我运行这个main.cpp
:为什么typeid.name()使用GCC返回奇怪的字符,以及如何让它打印未加密的名字?
#include <iostream>
#include <typeinfo>
using namespace std;
struct Blah {};
int main() {
cout << typeid(Blah).name() << endl;
return 0;
}
通过与GCC 4.4.4版本编译它:
g++ main.cpp
我得到这个:
4Blah
基于Visual C++ 2008,我会得到:
struct Blah
有没有办法让它只是打印Blah
或struct Blah
?
[C++中打印变量类型]的可能重复(http://stackoverflow.com/questions/81870/print-variable-type-in-c) – 2015-06-18 15:13:03
[Unmangling std :: type \ _info :: name](http://stackoverflow.com/questions/281818/unmangling-the-result-of-stdtype-infoname) – bain 2016-11-20 23:54:35