类名宏 [英] Class name macro
本文介绍了类名宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
C ++中的CLASS 宏
Possible Duplicate:
CLASS macro in C++
您好,有什么方法可以通过函数名称获取类似于 __ FUNCTION __ 的宏的类的名称吗?我唯一的想法是继承带有纯虚拟 toString 的一些基类,并通过手动方式定义名称.谢谢.
Hello, are there any ways to get name of class with macro like __FUNCTION__ for function name? The only ideas I have is inheriting some base class with pure virtual toString and define the names by hands eash time. Thanks.
推荐答案
使用宏定义类:
#define CLASS_WITH_NAME(name) name { const char * __NAME = #name;
class CLASS_WITH_NAME(class_name) // No "{" here!
骇客骇客,但我能想到的最好的
Ugly hack but the best I can think of.
这篇关于类名宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文