|
|
|
|
|
by pjmlp
2515 days ago
|
|
Here is pass by reference and pass by pointer in Pascal. type
Point = record
x, y : integer
end;
procedure ByPointer(p : ^Point);
begin
p^.x := 12
end;
procedure ByReference(var p : Point);
begin
p.x := 12;
p.y := 33
end;
procedure example
var
p : Point
begin
p.x := 23;
p.y := 28;
WriteLn('The point is ', p.x, ' ', p.y);
ByPointer(@p)
WriteLn('The point is ', p.x, ' ', p.y);
p.x := 23;
p.y := 28;
WriteLn('The point is ', p.x, ' ', p.y);
ByReference(p)
WriteLn('The point is ', p.x, ' ', p.y);
end;
Actually the concept is already exposed in Algol, a couple of years before C was even an idea. |
|