Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 C++ 中,我可以使用typeid运算符来检索任何多态类的名称:
typeid
const char* name = typeid( CMyClass ).name();
返回的const char*指针指向的字符串对我的程序可用多长时间?
const char*
只要具有 rtti 的类存在。因此,如果您处理单个可执行文件 - 永远。但是对于动态链接库中的类,它会发生一些变化。可能你可以卸载它。
返回的内存type_info::name()将在应用程序的生命周期内可用。
type_info::name()