The following code gives a weird output. I have tried it on multiple compilers and ended up with the same answer. It will process the statement right to left but print the output left to right however c++ statements are evaulated left to right in general. Can someone explain why this happens when we overload the cout statement.
Output: 15 10 5
However the Output if processed from left to right should be: 8 10 12
#include<iostream>
using namespace std;
int main(){
int a = 5, b = 3, c = 2;
cout<< (a = b + a) << endl << (b = c + a) << endl << (c = b + c);
return 0;
}