Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ARGG! VFP send my objects by reference, no by value!!!!
Message
 
To
07/03/2000 22:24:15
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00342323
Message ID:
00343537
Views:
32
>C/C++:
>
>int someFunc(void **ppint);
>
>And I have seen it (in COM literature for example) cast like:
>
>x = someFunc((void**) *&pvar);

COM objects are always by reference. You never have a pointer to the actual object, just a pointer to the interface which in turn has the VTABLE to the actual entry point offsets. So COM objects are always doubly derereferenced which is what that syntax above is. It's the address of the Interface pointer.

Bottom line is in COM and VFP a like - there's always only a single instance of an object no matter how many reassignments or passings to methods occur. The only way to create a new object is do CreateObject() or CoCreateInstance on it.

In C++ you can create native, static object variables. Those are essentially structures which can be passed by value or by reference and they will exhibit different behaviors with the former causing a copy to be made of the object structure. By value means copying a memory footprint - it's very inefficient to do this for complex objects. If you have references to other objects those will still be object references that won't be copied for example unless they're embedded.

In general there's no need to ever pass an object by value - if you do, I'd say there's a design problem that can be solved easily by creating data members that can be copied.












>
>What is the reason for this?
>
>TIA,
>Bill
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform