return list of values between parenthesis (10, 20, 30, 40)?

后端 未结 4 1231
自闭症患者
自闭症患者 2020-12-06 14:23

I am working in C++ (not C++/CLI) in Visual Studio 2012.

I don\'t understand why this code works, I would have expected it to fail

4条回答
  •  时光说笑
    2020-12-06 15:12

    The comma operator is a 'sequence point' in C++, often used to initialise multiple variables in for loops.

    So the code is evaluating a series of integers, one at a time, as single expressions. The last of these is the returned value, and the return statement as a whole is equivalent to simply return (40);

提交回复
热议问题