When an operator cannot be applied to the operands it was given, such as when a boolean operator is applied to a pointer, this error message is displayed.
program Produce; var P: ^Integer; begin if P and P^ > 0 then Writeln('P points to a number greater 0'); end.
In this case, a C++ programmer was unsure about operator precedence in Delphi because P is not a boolean expression and the comparison must be parenthesized.
program Solve; var P: ^Integer; begin if (P <> nil) and (P^ > 0) then Writeln('P points to a number greater 0'); end.
The compiler is pleased if we explicitly compare P to nil and use parentheses.
Leave a Reply