confusion of comma operator in variable initializations

82 Views Asked by At

If i'm not wrong, (1,2,3,4,5) expression will evaluate to 5( the order of evaluation is from left to right), then why int m({1,2,3,4,5}) is not being compiled fine?

Following is the compile-time error message. cannot convert '<brace-enclosed initializer list>' to 'int' in initialization

Don't mind, i'm new to C++, please correct my understanding, I just know that an expression with comma operator is evaluated from left to right and the rightmost value is then returned in the evaluation, but( according to my wrong understanding) here the inner expression should be evaluated to 5 and m should be initialized with value 5 fine.

I'm using Dev-C++ with TDM-GCC 4.9.2 64 bit release( i don't know how to find the running version of c++, whether it's c++11 or earlier version).

Please guide me. Thanks a lot!

0

There are 0 best solutions below