In Delphi, objects are special pointers which refer to a data structure on heap memory. When you pass an object to a function, you are actually passing the pointer, not a copy of the whole object data. In this case, when you modify a field or property via that reference, it will affect the original object data. Here is a simple example demonstrating this behavior:
program ObjParamTest;
type
TMyClass = class
private
FMyField : Integer;
public
property MyField : Integer read FMyField write FMyField;
end;
function ModifyObject(AnObj: TMyClass);
begin
AnObj.MyField := AnObj.MyField + 1;
end;
var
MyObj : TMyClass;
begin
MyObj := TMyClass.Create;
try
AnObj.MyField := 2;
Writeln(AnObj.MyField); // ==> Prints 2
ModifyObject(MyObj);
Writeln(AnObj.MyField); // ==> Prints 3
finally
MyObj.Free;
end;
end.
Also take note, parameter modifiers (e.g. Var, Const, Out) only change the way the object reference is passed to the function, and have no effect on the original data structure.
Maybe this article clears up things about different ways of passing parameters to functions in Delphi for you more:
http://vcldeveloper.com/articles/different-function-parameter-modifiers-in-delphi/
Regards