“ ##”的含义是什么?在C ++宏中?
问题描述:
下面的 ##是什么意思?
What's the meaning of "##" in the following?
#define CC_SYNTHESIZE(varType, varName, funName)\
protected: varType varName;\
public: inline varType get##funName(void) const { return varName; }\
public: inline void set##funName(varType var){ varName = var; }
答
运算符##连接两个参数,不留空白它们之间的空格:
例如
The operator ## concatenates two arguments leaving no blank spaces between them: e.g.
#define glue(a,b) a ## b
glue(c,out) << "test";
这也将转换为:
cout << "test";