假设我有一堂课myClass < handle
。在Mathworks 帮助页面上clear
,
清除句柄图形句柄不会删除对象本身,删除对象也不会删除存储其句柄的变量。
hf = figure; % Creates figure object, stores handle in variable hf
delete(hf) % Removes figure object, but not the variable hf
clear hf % Removes hf from the workspace; figure could still exist
所以clear
ing 一个句柄对象不会将它从内存中删除,除非我delete
首先明确它..
我指定了一个析构函数myClass
来进行适当的清理并删除对它的一些引用;不调用此析构函数clear
。当我的对象被清除时,是否可以调用该析构函数?
编辑:我应该提到,如果没有对对象的引用,delete
则会自动调用 a ,但我有另一个类,比如引用 的属性,比如。另外还有其他属性不是 的属性,但如果也是空的,它们应该是空的。让我知道如果这没有意义,那可能有点太罗嗦了。clear
myClass
myOtherClass
myClass
myOtherClass.a
myOtherClass
myClass
myOtherClass.a