Ross

As far as I am aware there is no way of cloning an object directly - you
must create a new instance and then copy each attribute explicitly. Note
that if any of the of the attributes are pointers  or class instances then
be very careful about the lifetime management of the objects being pointed
at as you may free them when destroying one object and cause an exception
when the cloned object later references those attributes.
One approach I have taken is to provide a constructor called Clone with the
cloner as a parameter and code it so it copies all the relevent attributes
to the new instance - so to get a clone you simply -

Clonee := TMyObject.Clone(Cloner);

Basically tho' its an area that is fraught with problems and needs careful
thought for any but the most simple cases ..

Hope this helps

Paul Lowman

Lowman Consulting Ltd.
Embedded Systems & Software

[EMAIL PROTECTED]

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to