开发者

How can I use two dimensional dynamic array as a Function parameters?

hi i Have a problem when I use a t开发者_StackOverflow社区wo dimensional dynamic array. I use this: procedure ListDeleted(FilesList: array of array of Integer); Delphi give me compile error How can I fix it?


Declare the array type first, then use it in the parameter list

type
  T2DIntArr = array of array of Integer;

...

ListDeleted(FilesList: T2DIntArr);


Define a custom type:

type
  TIntArray2 = array of array of Integer;

If you just read the parameter content in ListDeleted, use

 procedure ListDeleted(const FilesList: TIntArray2)

If the parameters are about to be modified internaly , use

 procedure ListDeleted(var FilesList: TIntArray2)

If the parameters are to be modified internally, but the modification should not be propagated to the caller, use

 procedure ListDeleted(FilesList: TIntArray2)

But notice that the last declaration (with no const nor var) will make a temporary copy of the array before calling ListDeleted, which is not a good idea for performance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜