+ 3

Why compiler compiles from right side?

My teacher, in my school ,told me that the compiler compiles a cout statement from right eg:- //some code B=67; cout<<"@"<<--B; cout<<"@"<<char(B+1)<<++B; //output @66@D67 in this case the program first decrements the value of B by 1 then in the next line it starts from right increments the value prints the value of char(B+1) which becomes D otherwise it should be C... can anyone explain me this why compiler compiles from right side..? https://code.sololearn.com/c8GjK6moEOys/?ref=ap

2nd Nov 2017, 10:22 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
2 ответов
+ 3
Using the ++ or -- operators in a cout statement is very unpredictable. Another example. This was discussed in comments. https://code.sololearn.com/cBg3yJKuyCM9/?ref=app
2nd Nov 2017, 2:16 PM
Bob
Bob - avatar
+ 3
yeah in CPP droid it shows me C instead of D
2nd Nov 2017, 11:23 AM
Saurabh Tiwari
Saurabh Tiwari - avatar