#include <iostream>
#define func(x) x*x-x
usingnamespace std;
class abcd {
public:
staticint a;
int b;
abcd(int x) {
b=x;
a=b+1;
}
};
int abcd::a=0;
int f, x=10, y=10, i=2;
char *s = "ABCD";
int *z = &x;
int main(void) {
cout << "func(i+3) is " << func(i+3) << endl;
f = (x==y);
cout << "f is " << f << endl;
while (++i<5) f *= i;
cout << "f is " << f << endl;
x = (x++ > y) ? (x+y) : (x-y);
cout << "x is " << x << endl;
x = y++ + x++;
y = ++y + ++x;
cout << "x is " << x++ << endl;
cout << "y is " << ++y << endl;
}
For the code above I get the output of func(i+3) is 20 using the #define function x*x-x. But the actual output is 12.
Also f is not assigned to anything but output is 1.
Can somebody please explain me how this code works?
indentation
<nolyc> indentation is optional whitespace. see also: !vowel
vowel
<nolyc> vwls r bt s sfl s whtspc, spclly n vrbl nms. s ls: !ndnttn
ndnttn
<nolyc> indentation is optional whitespace. see also: !vowel
func(i+3) expands to `i+3*i+3-i+3'
> Also f is not assigned to anything but output is 1.
¿what did you expected then?
However you do have `f = (x==y);'
By the way, lines 25 and 26 have undefined behaviour
I haven't done programming for a while. I think my mind completely forgotten about boolean expression. Thanks for helping me Stewbond ,
ne555 & booradley60.