Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this C++ code compile? What does it do? [duplicate]

Tags:

I had this problem when I accidentally deleted the method name. The code went from

bool bRet = MethodName(pData, pOutFilename); 

to

bool bRet = (pData, pOutFilename); 

but still compiled? What does this code do? What does it mean? It seems to return true, is this always the case (even if pData is null)?

Any ideas are welcome!

like image 968
Danny Birch Avatar asked Jul 22 '13 10:07

Danny Birch


People also ask

What does duplicate function declaration mean?

Duplicate function definitions (a particular type of function declaration - which implements the function) are a problem. Practically, a compiler will give warnings or errors when multiple definitions of a function occur in a compilation unit.

What does duplicate symbol mean in C++?

Solution. Duplicate symbols occur when you have both added an implementation file (. cpp) to your project and #included it. This way, the implementation file (. cpp) gets compiled twice: once as a module in your project (as it is added to your project) and subsequently as a piece of #included code.


1 Answers

it is the "comma operator" which

evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).

like image 54
Stefano Falasca Avatar answered Oct 05 '22 23:10

Stefano Falasca