1. 符号"\"
用于多行定义,每行的最后加上"\"
#define MAX(a,b) \
if(a>b)\
return a;\
else\
return b;
2.符号"#“和”##"
#是把参数字符串化, ##是连接两个参数
#include <iostream>
using namesapce std;
#define A(x) x
#define B(x) #x
#define C(x,y) x##y
int main()
{
cout << A("hello")<<endl;
cout<<B(hello)<<endl;
cout<<C("hello","world")<<endl;
}
结果:
hello
hello
helloworld