🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #32416

Re: How to copy an object?

#32416
From: Mike Williams (TeamB)
Date: Sun, 24 Nov 2002 21:36
20 lines
1579 bytes
On 24 Nov 2002, "Frank. C." <gcherem@nospam.hotmail.com> wrote:

> How do I create copy of an existing object?
> 
> var
>   NewObject: TObject;
> 
>   NewObject <- copy of ExistingObject

The normal technique is for the class to have an assign method that does a 
field by field copy.  Therefore, the syntax would be:

NewObject := tSomeObject.Create;
NewObject.Assign(ExistingObject);

The reason there's no automatic way of copying an object is that there are 
different types of copies, i.e, deep vs shallow copies.

-- 
-Mike
Technical Details
Message-ID: <Xns92D0A9499D423mikewteamb@207.105.83.65>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail
References: <3de13ff9@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d30,e9d3d7b4364ba410
X-Google-Attributes: gid109d30,public
X-Google-ArrivalTime: 2002-11-24 14:15:38 PST
Newsgroups: borland.public.delphi.language.objectpascal
Subject: Re: How to copy an object?
From: "Mike Williams (TeamB)" <mikew@remove.aps-soft.com>
References: <3de13ff9@newsgroups.borland.com>
Organization: APS, Inc.
Message-ID: <Xns92D0A9499D423mikewteamb@207.105.83.65>
User-Agent: Xnews/05.08.12
X-Face: ]UmEAWdR|b}vY~FGoYRU~Hg>>\c}p{T#9xunMJz$%I7&yn|g4oH}!nk#rE-qX2i5\l%yHMbqYrC|%"97nxm,4o>TV-bT&_m~8X1$^c8*&"{)A43s>M5v)j;)EDa.<EwjCTdyApmr23vO0a:oJ1e_fII`W&P*au%-Ld:v
NNTP-Posting-Host: 209.187.140.74
Date: 24 Nov 2002 13:36:41 -0800
X-Trace: newsgroups.borland.com 1038173801 209.187.140.74 (24 Nov 2002 13:36:41 -0800)
Lines: 20
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-05!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!news.uni-x.net!newsgroups.borland.com!not-for-mail