E2015 Operator not applicable to this operand type (Delphi)
Go Up to Error and Warning Messages (Delphi)
This error message is given whenever an operator cannot be applied to the operands it was given - for instance if a boolean operator is applied to a pointer.
program Produce; var P: ^Integer; begin if P and P^ > 0 then Writeln('P points to a number greater 0'); end.
Here a C++ programmer was unclear about operator precedence in Delphi - P is not a boolean expression, and the comparison needs to be parenthesized.
program Solve; var P: ^Integer; begin if (P <> nil) and (P^ > 0) then Writeln('P points to a number greater 0'); end.
If we explicitly compare P to nil and use parentheses, the compiler is happy.