Result of comma operator as l-value in C and C++
Using the result of the comma operator as l-value is not valid in C. But in C++, the result of the comma operator can be used as l-value if the right operand of the comma operator is l-value. For example, if we compile the following program as a C++ program, then it works and prints b = 30. And if we compile the same program as a C program, then it gives a warning/error in the compilation (Warning in Dev C++ and error in Code Blocks).
OUTPUT: error: lvalue required as left operand of assignment
a = 10 b = 30
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
My Personal Notes arrow_drop_up
Please Login to comment...