+ 2

What is "int x = (a,b,c)"?

I have never come across the statement of the form "int x = (a, b, c)" of type int until I took a quiz today about it. If a is 1, b 2, and c 3, then x is 3. What is this feature, how does it operate, and how is it useful?

19th Sep 2019, 7:19 PM
Duck Typed
Duck Typed - avatar
1 ответ
+ 2
After some searching I found part of my answer: it is an initializer much like int x = 3, int x = (3), int x (3), int x {3}, etc. It always sets the left-value to the last element of the initializer. I do not know why programmers would want to use it though when the other values are unused.
19th Sep 2019, 7:35 PM
Duck Typed
Duck Typed - avatar