[fpc-pascal] various ways of passing a class instance as a parameter

Graeme Geldenhuys graemeg.lists at gmail.com
Tue Nov 15 11:00:34 CET 2011


On 15/11/2011, Martin Schreiber <mse00000 at g.....> wrote:
>

Thanks Martin. Extending my example by changing the body of foo() too...

  AClass.Free;
  AClass := TStringList.Create;
  AClass.Add('inside foo');

...reveals a bit more about the differences.



>> procedure foo(const AClass: TStringList);
>>
> Take a copy of the AClass instance pointer, AClass is readonly.


This one confused me a bit. I thought the whole object would be
read-only, but in fact it is just the AClass instance pointer which
cannot be modified. The properties of AClass are still read-write.


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net



More information about the fpc-pascal mailing list