有什么需要初始化多维动态数组? [英] What needs finalization in a multidimensional dynamic array?

查看:105
本文介绍了有什么需要初始化多维动态数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用动态数组很大,并有与SetLength函数没有问题,最终确定程序。

I use dynamic arrays a great deal and have no problems with the SetLength and Finalize procedures.

最近,我的事业使用动态数组,其中每个数组元素本身可能包含不同数量的元素。该声明是这样的:

I recently had cause to use dynamic arrays where each array element could itself contain a variable number of elements. The declaration is like this:

TScheduleArray =  array of array of array [1..DaysPerWeek] of TShiftType;

该软件工作正常,我没有得到一个问题的如何的使用这种结构。你叫的 SetLength函数的主阵列,然后可以在每个数组元素上调用的 SetLength函数的一次。这是工作正常。

The software is working fine, I've not got a problem with how to use this structure. You call SetLength on the main array and then can call SetLength again on each array element. This is working as expected.

SetLength(MyArray, 1);
SetLength(MyArray[0], 2);

我的问题是这样的:当我来到释放用于该阵列的资源,我只是调用的敲定的对数组变量:

Finalize(MyArray);

或确实每个数组元素也需要的的Finalize 的D,如每个元素是一个动态数组本身

or does each array element also need to be Finalized, as each element is a dynamic array itself?

推荐答案

该阵列由编译器管理,并不需要最后确定。如果TShiftType是一个类,你必须手动释放的对象,一次一个,但是当它超出范围数组本身将被妥善处理。

The arrays are managed by the compiler and don't need to be finalized. If TShiftType is a class, you'll have to free the objects manually, one at a time, but the array itself will be disposed of properly when it goes out of scope.

这篇关于有什么需要初始化多维动态数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆