I work in C ++ (not C ++ / CLI) in Visual Studio 2012 .
I don’t understand why this code works, I would expect it to fail at compile time, but it doesn’t even work at runtime:
double MyClass::MyMethod() const
{
return (10, 20, 30, 40);
}
I made this code by mistake, it wasn’t on purpose, I noticed an error when I ran Unit tests. And I am surprised that this works. When I run it, it returns 40 , the last number in the list.
Can someone explain to me what this syntax means and why it works?
source
share