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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -