문제

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

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

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

도움이 되었습니까?

해결책

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.

다른 팁

The memory returned by type_info::name() will be available for the application's lifetime.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top