You are viewing a single comment's thread. Return to all comments →
The preprocessor would replace each occurance of "abs(x)" by "((x) < 0 ? -(x) : (x))". Thus the code to be compiled would be:
int i = 0; cout << ((++i) < 0 ? -(++i) : (++i)) << endl;
This would lead i to be incremented twice. Once before checking if the conditional is true and the second time before evaluating the else clause.
Seems like cookies are disabled on this browser, please enable them to open this website
Pointer
You are viewing a single comment's thread. Return to all comments →
The preprocessor would replace each occurance of "abs(x)" by "((x) < 0 ? -(x) : (x))". Thus the code to be compiled would be:
int i = 0; cout << ((++i) < 0 ? -(++i) : (++i)) << endl;
This would lead i to be incremented twice. Once before checking if the conditional is true and the second time before evaluating the else clause.