宏定义1宏定义的规则和使用解析(1)宏定义的解析规则就是:在预处理阶段由预处理器进行替换,这个替换是原封不动的替换.(2)宏定义替换会递归进行,直到替换出来的值本身不再是一个宏为止.#define M 10#define N M(3)一个正确的宏定义式子本身分为3部分,第一部分是#define,第二部分是宏名,剩下的所有为第三部分.(4)宏可以带参数,称为带参宏.带参宏的使用和带参函数非常像,但是使用上有一些差异.在定义带参宏时,每一个参数在宏体中引用时都必须加括号,最后整体再加括号,括号缺一不…
宏定义是一个比较常考的考点,所以我归纳总结了一下近年的宏定义的题目 //宏定义面试题1.cpp//What is the output of the following code?[中国台湾某著名杀毒软件公司2005年10月面试题] #include<stdio.h> #define SQR(x) (x*x) void main() { ; a=SQR(b+); printf("/n%d",a); } //A. 25 B.11 C.Would vary from c…
1.Preprocessor Glue: The ## Operator 预处理连接符:##操作符 Like the # operator, the ## operator can be used in the replacement section of a function-like macro.Additionally, it can be used in the replacement section of an object-like macro. The ## operator co…