Makro Frage
-
Warum gibt er hier 4 aus und nicht 6?
#define BLA(x) x*2 int main() { int a,b; a = 2; b = BLA(a+1); cout << b; getchar(); return 0; }
-
Weil Makros eine blinde Textersetzung darstellen -
Bla(a+1)
wird zua+1*2
und den Ausdruck wertet der Compiler (Punktrechnung vor Strichrechnung) aus als "a+(1*2)" (und das ergibt 4).