In Delphi/Free Pascal: is ^ an operator or does it simply denote a pointer type?
Sample code
program Project1;
{$APPTYPE CONSOLE}
var
P: ^Integer;
begin
New(P);
P^ := 20;
writeln(P^); // How do I read this statement aloud? P is a pointer?
Dispose(P);
readln;
end
When
^is used as part of a type (typically in a type or variable declaration) it means “pointer to”.Example:
When
^is used as a unary postfix operator, it means “dereference that pointer”. So in this case it means “Print whatPpoints to” or “Print the target ofP“.Example: