Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我把这一行变成了一个类的宏定义
virtual const char *GetEventName() const { return #classname; }
这个函数和它的返回类型发生了什么?
Ifclassname是宏的参数之一,#classname是其值的字符串版本。所以如果classname是SomeType,#classname就相当于"SomeType"
classname
#classname
SomeType
"SomeType"
因为它返回一个字符串(c 字符串),所以返回类型是 const char*
有关更多信息,请查看字符串化