简体   繁体   中英

What is the return type of this function?

I got this line into a macro definition of a class

virtual const char *GetEventName() const
{
    return #classname;
}

What is happening in this function and its return type?

If classname is one of the arguements of the macro, #classname is a string version of its value. So if classname were SomeType , #classname would be the equivalent of "SomeType"

Since it is returning a string (c string) the return type is const char*

For more information look at Stringification

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM