copy or reference

  • Thread starter Thread starter Albert Krüger
  • Start date Start date
A

Albert Krüger

Hello,

when I return an object from a function, get I a copy or a reference to the
calling function?

function AnyFunction as MyClass
dim objectOfMyClass as MyClass
....
return objectOfMyClass
end function

objectOfCall = AnyFunction 'copy or reference?

I think a copy, but I am not sure.

Albert Krüger
 
Kruger,

With "object" types forever a reference.

Passing byval means passing the reference for those types. I assume that
because of your question that can give as well a misunderstanding for you.

I hope this helps,

Cor
 
Albert Krüger said:
when I return an object from a function, get I a copy or a reference to
the
calling function?

function AnyFunction as MyClass
dim objectOfMyClass as MyClass
...
return objectOfMyClass
end function

objectOfCall = AnyFunction 'copy or reference?

I think a copy, but I am not sure.

If 'MyClass' is a reference type (class), the function will return a
reference, otherwise (value type, structure) it will return a "copy".
 
Back
Top