1,返回指针值 Type PInt = ^Integer; function GetIntPointer: PInt; 2,指向函数的指针 Type MyFunc = function (i,j: Integer): Integer; function CompareInt(i, j: Integer): Integer; begin if i > j then Result := 1 else if i = j then Result := 0 else Result := -1; end; var P: MyFunc; begin p := CompareInt; if P(1, 2) > 0 then ShowMessage(1 is bigger than 2); end; 3,指针数组, 动态分配数据 var apInt: array[1..5] of PInt; PInt的定义在例子1里; p: PInt; i: Integer; begin for i := Low(apInt) to High(apInt) do begin New(p); p^ := 10 - i; end;
PASCAL中的函数能不能返回指针值
PASCAL中有没有指向函数的指针
PASCAL中有没有指针数组
PASCAL中怎样像C一样动态分配堆数据
上篇http://delphi.ktop.com.tw/topic.asp?TOPIC_ID=354
下篇http://delphi.ktop.com.tw/topic.asp?TOPIC_ID=360
PASCAL中有没有指向函数的指针
PASCAL中有没有指针数组
PASCAL中怎样像C一样动态分配堆数据
------------------------------------------
刚看你的这几个,不懂C,只知道前面三个是肯定的
Type
PInt = ^Integer;
function GetIntPointer: PInt;
2,指向函数的指针
Type
MyFunc = function (i,j: Integer): Integer;
function CompareInt(i, j: Integer): Integer;
begin
if i > j then
Result := 1
else if i = j then
Result := 0
else
Result := -1;
end;
var
P: MyFunc;
begin
p := CompareInt;
if P(1, 2) > 0 then
ShowMessage(1 is bigger than 2);
end;
3,指针数组, 动态分配数据
var
apInt: array[1..5] of PInt; PInt的定义在例子1里;
p: PInt;
i: Integer;
begin
for i := Low(apInt) to High(apInt) do
begin
New(p);
p^ := 10 - i;
end;
end;
最早的Pascal里是没有指针的,最好去查那个语言的文档