tags:

views:

151

answers:

4

Possible Duplicate:
C++ Comma Operator

what is result of operator ',' by standard? Last argument? in code like this, for example:

int a = 0; int b = 1;

while(a,b);

or using it like this is not allowed? MSVS thiks that result is b, is it true?

sorry for duplicating, did not know how this operator called in english )

+8  A: 

The sequence of statements is executed and the return value is the evaluation of the final statement.

Amardeep
Is it a statement or an expression?
Martin York
+5  A: 

The comma operator always returns its last argument, unless the operator is overloaded.

zildjohn01
+1 for mentioning "unless overloaded"
Steve Folly
+3  A: 

The result of the ',' operator is the last evaluated expression, yes.

Remy Lebeau - TeamB
+1  A: 

The result of , operator is its right-hand operand, i.e. the subexpression that follows ,.

Operator , is left-associative, meaning that if you have a chain of several , operators with operands and no braces, then the last subexpression in the chain is the result.

AndreyT