+ 1
The unpredictability of the order of Evaluation of Subexpressions
#include <iostream.h> main() { int n=5, x; x=++n*--n; cout<< "n = "<<n<<", x="<<x<<endl; cout<<++n<<" "<<++n<<" "<<++n<<endl; }
5 Réponses
+ 8
yes, this is bad practise.
+ 6
Multiple prefix, postfix operators used on a single variable between two sequence points would result in undefined behaviour. The end result is dependent on the compiler.
+ 3
operator precedence comes into play then , remembering them will be a life saver.
c++ is good in this aspect , js gives weird output in more cases.
c++ precedence chart
http://en.cppreference.com/w/cpp/language/operator_precedence
0
I am unableto understand this. Can anyone help?