Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ARGG! VFP send my objects by reference, no by value!!!!
Message
From
07/03/2000 18:05:14
 
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00342323
Message ID:
00343002
Views:
26
>An object passed by val........oNewObj = (code to duplicate oObjeRef as a new instance)

Ed, would this then be the equivalent of the function of a copy constructor in C++?

This got me thinking. would this be sufficient to implement this(is deep copy the right term?) in VFP?
oObj = CREATEOBJECT("someObj")
* Do stuff with oObj
oNewObj = oObj.copy()

* someObj::copy
n = AMEMBERS(la_props,this)
o = CREATEOBJECT ("someObj")
FOR x = 1 TO n
  o.&la_props[x] = this.&la_props[x]
ENDFOR
RETURN o

* someObj::Error
LPARAMETERS nError, cMethod, nLine
IF UPPER(cMethod) = "COPY"
  IF nError = 1743  && Property "name" is read-only
    RETURN .t.
  ENDIF
ENDIF
* Normal error handling goes here
Does that look right?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform