I've recently started to learn c++ and while I was testing myself with possible interview questions, I've ran into that chunk of code:
#include <iostream>
void F(int& y, int& x) {
std::cout << x++ << --y;
}
void main() {
int a = 5;
F(a, a);
std::cout << a;
}
And the output is:
455
So I do know that preincrement is faster than postincrement, but why if we swap arguments like:
...
std::cout << --y << x++;
...
the output suddenly changes to
555