On Wed, 27 Aug 2003 16:50:36 +1200, you wrote:

>Hi all
>
> 
>
>I want to copy the state (variables) of one instance object of a class, to
>another instance object of the same class. Eg. Class TDog, instance Dog1 and
>Dog2. I could do the following:
>
>Dog2.Colour := Dog1.Colour;
>
>Dog2.Breed := Dog1.Breed;    etc.
>
>But this seems a little silly. How do I do this in OO?

The convention is to provide a method in the TDog class (e.g. called
Assign).

This method knows how to correctly replicate the state of one TDog
instance in another (including private variables and any other hidden
internal state).

From the outside world you would then call  MyDog.Assign( YourDog );


--
Please remove '_SpamTrap' when replying.  You know why :-(

Peter Ingham
Lower Hutt
New Zealand
---------------------------------------------------------------------------
    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