首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于预加工""

2013-01-07 
关于预处理###define GET_ACCESSOR( x, y )inline x Get##y(){ return m_##y }怎么理解?[解决办法]$16.

关于预处理"##"
#define GET_ACCESSOR( x, y )       inline x Get##y()           { return m_##y; }

怎么理解?
[解决办法]
$16.3.3/3

For both object-like and function-like macro invocations, before the replacement list is reexamined for more macro names to replace, each instance of a ## preprocessing token in the replacement list (not from an argument) is deleted and the preceding preprocessing token is concatenated with the following preprocessing token. If the result is not a valid preprocessing token, the behavior is undefined. The resulting token is available for further macro replacement. The order of evaluation of ## operators is unspecified.


GET_ACCESSOR(int, Status ) 相当于
先替换为
inline int Get##Status()           { return m_##Status; }
然后删去##,前后相连
inline int GetStatus()           { return m_Status; }

热点排行