Is there a __CLASS__ macro in C++?(C++ 中有 __CLASS__ 宏吗?)
问题描述
C++ 中是否有一个 __CLASS__
宏,它给出的类名类似于给出函数名的 __FUNCTION__
宏
Is there a __CLASS__
macro in C++ which gives the class name similar to __FUNCTION__
macro which gives the function name
推荐答案
最接近的方法是调用 typeid(your_class).name()
- 但这会产生编译器特定的错误名称.
The closest thing there's is to call typeid(your_class).name()
- but this produces compiler specific mangled name.
要在类中使用它,只需 typeid(*this).name()
To use it inside class just typeid(*this).name()
这篇关于C++ 中有 __CLASS__ 宏吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ 中有 __CLASS__ 宏吗?


基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 常量变量在标题中不起作用 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01