Software & Finance





C++ - Comma Operator





Comma is an operator in C++. When comma is with in paranthesis, the right most argument is taken as a result otherwise left most.

 

    int a, b, m , n;

    a = 10;

    b = 20;

    m = (a,b); // m will hold the value of b which is 20

    n = a,b; // m will hold the value of b which is 10

    std::cout << m, n; // The code prints the output 20,10