指向typeinfo :: name()的内存的生命周期是多少? [英] What's the lifetime of memory pointed to typeinfo::name()?

查看:104
本文介绍了指向typeinfo :: name()的内存的生命周期是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++中,我可以使用 typeid 运算符来检索任何多态类的名称:

In C++ I can use typeid operator to retrieve the name of any polymorphic class:

const char* name = typeid( CMyClass ).name();

返回的字符串指向多长时间 const char * 指针可用于我的程序?

How long will the string pointed to by the returned const char* pointer available to my program?

推荐答案

只要有rtti的类存在。所以如果你处理单个可执行文件 - 永远。
但是对于动态链接库中的类,它会有点偏移。您可以卸载它。

As long as the class with rtti exists. So if you deal with single executable - forever. But for classes in a Dynamic Link Librariy it shifts a little. Potentially you can unload it.

这篇关于指向typeinfo :: name()的内存的生命周期是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆