Comma-separated expression
(Eastvc was published on 9:00:20)
The comma-separated expression inherits from C. it is very likely that you often use this expression for-and while-, but in this regard, the language rules are much different from your own intuition. let's take a look at the usage of the comma-separated expression:
A single expression can contain multiple child expressions separated by commas,
Example:
If (++ X, -- y, Cin. Good ())/* Three expressions */
This if condition contains three comma-separated expressions. c ++ ensures that each subexpression is evaluated, but the value of the entire expression only depends on the value of the rightmost expression. Therefore, the above if condition sentence is only used in CIN. good () returns true to true.
The following is another example of commas:
Int J = 10;
Int I = 0;
While (++ I, -- J)
{
/*. J! = When 0, execute the while body repeatedly (Repeat as long as J is not 0 )*/
}
Running result:
I = 10;
J = 0;