#define MIN(X,Y)(X)<(Y)?(X):(Y)//https://baike.baidu.com/item/define/577777?fr=aladdin
#define N 20
int a = 10, s = 15, k = 10 * MIN(a, s);
cout << k << endl;
#define MIN(X,Y)(X)<(Y)?(X):(Y)这个式展开来int a = 10, s = 15, k = 10 * MIN(a, s)=>10*10<15?10:15;因此得到的结果就是15
#define MIN(X,Y)((X)<(Y)?(X):(Y))这个式展开来int a = 10, s = 15, k = 10 * MIN(a, s)=>10*(10<15?10:15);因此得到的结果就是100
如果修改宏定义的话:#define MIN(X,Y)(X<Y?X:Y)那就是100或修改为#define MIN(X,Y)((X)<(Y)?(X):(Y))那也是100
C++宏定义
最新推荐文章于 2024-11-11 21:48:36 发布