Search code examples
c++ccomma-operator

Comma operator in a conditional


I have read in a lot of places but I really can't understand the specified behavior in conditionals.

I understand that in assignments it evaluates the first operand, discards the result, then evaluates the second operand.

But for this code, what it supposed to do?

CPartFile* partfile = (CPartFile*)lParam;
ASSERT( partfile != NULL );
bool bDeleted = false;
if (partfile,bDeleted)
    partfile->PerformFileCompleteEnd(wParam);

The partfile in the IF was an unnecessary argument, or it have any meaning?


Solution

  • In this case, it is an unnecessary expression, and can be deleted without changing the meaning of the code.