我试图在这里理解这段代码:
#include <iostream>
using namespace std;
#define mymult(a, b) a*b
inline int mymult1(int a, int b) {return a*b;}
int main() {
cout << "mymult(2+2, 3+3) = " << mymult(2+2, 3+3) << "\n";
cout << "mymult1(2+2, 3+3) = " << mymult1(2+2, 3+3) << "\n";
}
mymult = 11 和 mymult1 = 24。我知道 '#define 本质上是通过名称调用而不是值调用来工作的。但是,我无法理解为什么它返回的值是 11... 而不是 24。这是什么原因造成的?