有人可以解釋爲什麼b = 150?C++預處理器中的前綴增量
#define CUBE(X) ((X) * (X) * (X))
using namespace std;
int main(void)
{
int a = 3,b = 0;
cout << "before "<< endl;
cout << "a = " << a;
cout << endl;
cout << "b = " << b;
cout << endl;
cout << "after"<< endl;
b = CUBE(++a);
cout << "a = " << a;
cout << endl;
cout << "b = " << b;
getchar();
return 0;
}
[C,C++預處理器宏]的可能的重複(http://stackoverflow.com/questions/1263607/cc-preprocessor-macro) – 2011-05-30 19:40:56
@BoPersson:相關,但不是重複...不僅僅是因爲那個在序列點之間通過遞增多次不具有UB特徵。 – 2011-05-30 21:14:13