我需要维护一组对象引用并将每个项目传递给函数来管理它。我知道我可以做这样的事情:
Dim arrObjs As MyObject[]
Dim refObj As MyObject
arrObjs.Add(New MyObject) 'First reference to the Object.
refObj=arrObjs[0] 'Second reference to the same Object.
我认为这是对的,但是阅读 Gambas 对象模型文档时,我读到通过引用 (ByRef) 传递参数时不涉及指针。相反,该值被复制到函数内部,然后在函数完成后再次复制到函数外部。例子:
Sub manageObject(ByRef refObj As MyObject)
.....
End
通话时间:
manageObject(ByRef arrObjs[0])
如何管理对过程中对象的真实引用?有没有类似的东西?
Dim obj As New MyObject 'Correct
Dim objInstance As MyObject 'Correct
Dim refObj as Pointer 'Correct
refObj=varPtr(obj) 'NOT Correct, but i would like
objInstance=Object@(refObj) 'NOT Correct, but i would like