它的工作方式与将它们编写为单个语句一样:
int a = 1;
int b = 2;
int c = 3;
int d = 4;
a = b;
c = d;
更多详情,另请参阅Comma Operator
来自维基百科:
int a=1, b=2, c=3, i; // comma acts as separator in this line, not as an operator
i = (a, b); // stores b into i ... a=1, b=2, c=3, i=2
i = a, b; // stores a into i. Equivalent to (i = a), b; ... a=1, b=2, c=3, i=1
i = (a += 2, a + b); // increases a by 2, then stores a+b = 3+2 into i ... a=3, b=2, c=3, i=5
i = a += 2, a + b; // increases a by 2, then stores a into i. Equivalent to (i = a += 2), a + b; ... a=3, b=2, c=3, i=3
i = a, b, c; // stores a into i ... a=5, b=2, c=3, i=5
i = (a, b, c); // stores c into i