Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I pass an object property by reference?
Message
De
28/02/2001 14:05:30
 
 
À
28/02/2001 10:46:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00480283
Message ID:
00480653
Vues:
11
>>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).
>

An array property is not a pointer, it's a get method of an object.

>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.

This is the exact same as with VFP. You haven't commented on how VB handles array properties


>In Java, all natural types (int, char, float, etc.) are passed by value and all objects (String, Frame, etc.) are passed by reference.

Same with VFP. Simples types are passed by value, objects by reference.
Erik Moore
Clientelligence
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform