function DoubleVal (Val: Integer) : Integer;
begin
Val := Val * 2;
Result := Val;
end;
function DoubleRef (var Val: Integer): Integer;
begin
Val := Val * 2;
Result := Val;
end;
调用:
var
I, J: Integer;
begin
I := 2;
J := DoubleVal (I); // I = 2; J = 4;
//如果调用下面的话,
// J := DoubleRef (I); // I = 4; J = 4; i的值改变了
原文地址:https://www.cnblogs.com/bwdblogs/p/10344893.html
时间: 2024-11-02 23:40:38