1) C + + and--the function of the operator is increment and decrement, can be used as prefix or suffix expression;
int a = 1,B,C;B=A++;//1C=++A;//2
The difference between 1 and 2 is that the value of a in 1 is assigned to B, the value of a is increased by 1, so a b=1;2 starts with a 2,a increment of 1 and assigns a value to c,c=3; the last a=3.
y = (4 + x + +) + (6 + x + +);
2) The result of this expression is different from the result of running in different systems, because C + + chooses when to use the + + (-) operator for the variable as ";" to confirm. C + + does not guarantee that the value of x after (4 + x + +) immediately increases 1,c++ only to ensure that the value of x is increased two times at the end of the last type.
3) and pointer operator * Priority comparison: prefix increment and the * operator have the same precedence, followed by a right-to-left combination, the suffix increment precedence is higher than the prefix increment, but the suffix is incremented in a left-to-right way to combine.
Double x = *++pt;
The PT is a pointer, which means to add 1 to the next element and then add 1 to the value of the element that points to it.
4) for user-defined types, prefixes are more efficient to operate. The implementation of the suffix operation requires two steps (1) to copy the object, get the object copy (2) object plus 1, return the copied copy
This article is from the "leaf" blog, please be sure to keep this source http://fshine.blog.51cto.com/6122608/1582995
Analysis of + + and--in C + +