C++ 中有 __CLASS__ 宏吗? [英] Is there a __CLASS__ macro in C++?

查看:17
本文介绍了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__ 宏吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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