Information générale
Catégorie:
Programmation Orientée Object
>I don't know first hand, but I doubt you'll find this functionality in other languages either. If you want to be able to change the property in a subroutine, pass a reference to the object. I think that the ability to pass a property by reference would lead to some hairy referencing issues, as well as some behind the scenes complications for any environment. For instance- does passing the property by reference increase the object's reference count?
The other languages I was refering to are VB and Java in particular (I'm pretty sure that it can be done in C++ since an array is but a pointer and anything passed as a pointer is the equivalent of being passed by reference but I'm not 100% sure).
In VB, you specify the way a parameter is passed in the receiving function with the reserved words ByRef or ByVal. So the function knows that it will receive a variable and that whatever changes occur in that variable will affect the original variable that was passed. Plus, I don't think that you can specify either ByVal or ByRef for an array in VB because arrays are always used by reference.
In Java, all natural types (int, char, float, etc.) are passed by value and all objects (String, Frame, etc.) are passed by reference. It is very simple and so, for example, if you wanted to pass a "natural type" variable by reference, you would need to store it in an object to do it. This is, now that I think of it, a little like what you would need to do in VFP.
Anyway, thank you all very much for your inputs, I will rebuild my function so that it can take either an array or an entire object as a reference.
Thanks again, Stephane.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement