[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Copying objects
- Subject: Copying objects
- From: James Tappin <sjt(at)star.sr.bham.ac.uk>
- Date: Tue, 30 Nov 1999 15:54:07 +0000
- Newsgroups: comp.lang.idl-pvwave
- Organization: University of Birmingham
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:17568
Is there a "clean" way to make a copy of an object. The best I could do for a
nice easy case with no pointers or object references in the class was:
pro Object1::set_all, tstr
for i = 0, n_tags(tstr)-1 do self.(i) = tstr.(i)
end
function Object1::copy
temp = {object1}
for i = 0, n_tags(temp)-1 do temp.(i) = self.(i)
newobj = obj_new('object1')
newobj -> set_all, temp
return, newobj
end
While it works,  it seems to be a bit of a kludge. Is there a better way?
James
-- 
+------------------------+-------------------------------+---------+
| James Tappin           | School of Physics & Astronomy |  O__    |
| sjt@star.sr.bham.ac.uk | University of Birmingham      | --  \/` |
| Ph: 0121-414-6462. Fax: 0121-414-3722                  |         |
+--------------------------------------------------------+---------+