|
-
August 22nd, 2001, 04:18 AM
#1
copy a class
If I have 2 declarations of class object
DIM Cls as ADefinedClass
DIM ClsOld as ADefinedClass
SET Cls =new ADefinedClass
CLS.ID ="ABC"
SET ClsOld =Cls
' ------1 at this point ,ClsOld.id='ABC"
CLS.ID="CCC"
' ------2 at this point ,ClsOld.id='CCC"
Question:--
How I programme the code if I want the ClsOld to have a copy of old cls ,one that its .ID will not changed whenever Cls Changed.
It means that at point --2, I want the ClsOld.ID to remain as "ABC"
-
August 22nd, 2001, 04:55 AM
#2
Re: copy a class
SET ClsOld =Cls -> now ClsOld e Cls are set to the same object. To make a copy of a class U must for example add a method in ADefinedClass.
public function Clone() as ADefinedClass
dim newc as ADefinedClass
newc.id=me.id
set Clone = newc
end function
DIM Cls as ADefinedClass
DIM ClsOld as ADefinedClass
SET Cls =new ADefinedClass
CLS.ID ="ABC"
SET ClsOld =Cls.clone
' ------1 at this point ,ClsOld.id='ABC"
CLS.ID="CCC"
' ------2 at this point ,ClsOld.id='ABC"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|