I encountered a line of code:
int a = 10;
int b = 40;
a = a + b - (b = a);
cout << a << " " << b << endl;
I cannot understand what happens in this code.
Can anyone explain for me?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Undefined behavior. the value of
bis changed and used for computation without an intervening sequence point. The results of the program are unpredictable – it can print anything or crash, or do do some nasty system calls.