W
wjiachun
Unregistered / Unconfirmed
GUEST, unregistred user!
>>ThreadFunc(nil),nil是pointer???
To see how pointers work, look at the following example.
1 var
2 X, Y: Integer
// X and Y are Integer variables
3 P: ^Integer
// P points to an Integer
4 begin
5 X := 17
// assign a value to X
6 P := @X
// assign the address of X to P
7 Y := P^
// dereference P
assign the result to Y
8 end;
Line 2 declares X and Y as variables of type Integer. Line 3
declares P as a pointer to an Integer value
this means that P
can point to the location of X or Y. Line 5 assigns a value to X,
and line 6 assigns the address of X (denoted by @X) to P. Finally,
line 7 retrieves the value at the location pointed to by P (denoted
by ^P) and assigns it to Y. After this code executes, X and Y have
the same value, namely 17.
To see how pointers work, look at the following example.
1 var
2 X, Y: Integer
// X and Y are Integer variables
3 P: ^Integer
// P points to an Integer
4 begin
5 X := 17
// assign a value to X
6 P := @X
// assign the address of X to P
7 Y := P^
// dereference P
assign the result to Y
8 end;
Line 2 declares X and Y as variables of type Integer. Line 3
declares P as a pointer to an Integer value
this means that P
can point to the location of X or Y. Line 5 assigns a value to X,
and line 6 assigns the address of X (denoted by @X) to P. Finally,
line 7 retrieves the value at the location pointed to by P (denoted
by ^P) and assigns it to Y. After this code executes, X and Y have
the same value, namely 17.