Delphi Sent TObjectList like var parameter -
i have class
tfolder = class node_index: integer; first_index : integer; code_name: ansistring; name: ansistring; constructor create(newnode_index, newfirst_index: integer; newcode_name, newname: ansistring); destructor destroy; override; end;
and have type
type tfolderlist = class (tobjectlist<tfolder>) end;
then try use type
taccount = class ... folders: tfolderlist; public constructor create(...); destructor destroy; override; procedure loadfoldersfromdisk(var _objectlist: tfolderlist); end;
when try send tobject list parameter
procedure tform1.formcreate(sender: tobject); begin ollocalfolders := tobjectlist<tfolder>.create(); account.loadfoldersfromdisk(ollocalfolders); end;
i error "types of actual , formal var parameters must identical". i'm doing wrong?
just replace tobjectlist<tfolder>
wtih tfolderlist
defined eariler:
procedure tform1.formcreate(sender: tobject); begin ollocalfolders := tfolderlist.create(); account.loadfoldersfromdisk(ollocalfolders); end;
however, not need use var parameter here - method name loadfoldersfromdisk
suggest method populate list sent parameter items, , can send list value. need use var parameter if method alert list object's memory location (as opposed it's content), ie when loadfoldersfromdisk
free original list , create new one.
Comments
Post a Comment