- 1
Problems with Increment Operator
How would we predict the following outputs: #include <iostream> int main() { int a = 1; std::cout << ++a + ++a + ++a << "\n"; a = 1; std::cout << ++a + a++ + a++ << "\n"; a = 1; std::cout << a++ + ++a + ++a; return 0; } Can you please explain why and when each increment takes place.
2 odpowiedzi
+ 2
value will assign from left to right.
- 1
9
7
8