I'm making some exercises in C++ and in this question, the compilers give me different answers. One gives me 11 and the another one gives me 10, and I don't know which is the correct.
#include <iostream>
using namespace std;
class A {
public:
A() { a.a = a.b = 1; }
struct { int a,b; } a;
int b(void);
};
int A::b(void) { int x=a.a;a.a=a.b;a.b=x; return x; };
int main(void) {
A a;
a.a.a = 0;
a.b();
cout << a.b() << a.a.b << endl;
return 0;
}
I tried to understand the differences but I didn't figure out. It's because in one compiler he reads from left to right and in the another one reads in the other way ?