#include <iostream> using namespace std; #define MULTIPLY(a, b) a*b int main(){ cout << MULTIPLY(2+3, 3+5); return 0; }
我希望这会打印40,因为五乘八等于四十。为什么打印16?
40
16
因为C ++宏不是函数。它们是文本副本,因此意味着:
cout << 2+3*3+5;
哪个是2 +(3 * 3)+ 5