
Originally Posted by
whburling
In fact, my question was really focused on the issue of objects being passed ByRef or ByVal.
Before I even read and think about and respond to the rest of this let me address this one sentence.
An object variable is itself a pointer that points to the state of the object. So if you pass an object ByVal, you are passing a copy of the pointer, but it is still pointing to the same object as the caller. This is completely different than how passing scalar variables works.
With regard to your original statement
It is commonly explained that passing an object ByRef passes a pointer to an object and passing an object ByVal passes a copy of the object.
This is 100% incorrect.
Here is an illustration of what happens if you pass an object by value and by reference.
Module code for class IntegerContainer:
Test code:
Output of test code:
Bookmarks