The @
operator means taking the address of a variable (getting a pointer to a variable)
The ^
operator in the code denotes dereferencing a pointer and getting the value of a variable.
The ^
operator when declaring a type means using a pointer. For example, PPoint = ^TPoint
means that an object of type PPoint
will be a pointer to an object of type TPoint
.
These operators complement each other.
var a: integer; b: pointer; begin a := 123; // теперь b указывает на a b := @a; // приводим указатель к конкретному типу и записываем в адрес, // на который указывает b - новое значение 120 // теперь a будет 120 PInteger(b)^ := 120; end;
What will happen in Pkts if Psh [4, 1] = 230?
Pkts[4, 1]:= @Psh[4, 1]^[9];
In Pkts[4,1]
will be an element with offset 9 from Psh[4,1]
.
Let's take a look at the steps, we get the address of the Psh variable [4,1], right there we deline it back into a variable, and from this variable we take an element (that is, it looks like a string or another array).
Please note that this code will not compile in Delphi, since The delimited type @Psh[4, 1]
not specified.
Pkts
andPsh
variablePkts
Psh
. Apparently they are multidimensional arrays - Kromster