Possible duplicate:
C ++ Comma Operator
About a year ago, I noticed some obscure syntax in the coding project that I was working on:
table_value = table_index += 2, valueFromTable(table_index);
Does anyone recognize this ?, it's like an assignment with an extra expression. This is compiled in the entire cross-platform compiler suite, so I'm pretty sure it is a valid C ++, but I have never seen anything like it.
Any insight would be appreciated.
Gearoid
EDIT: there is a working code:
#include <iostream>
using namespace std ;
int valueFromTable(int a) { return a ; }
int main()
{
int table_index = 0 ;
int table_value = table_index += 2, valueFromTable(12);
cout<<table_value<<endl;
return 0 ;
}
source
share