Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!ox.com!math.fu-berlin.de!unidui!unido!zwsbdf!philipps From: philipps@zwsbdf.uucp (Christian Philipps) Newsgroups: comp.lang.c++ Subject: Re: How do you copy a Derived object? Summary: deep clone Message-ID: <950@zwsbdf.uucp> Date: 12 Apr 91 10:36:27 GMT References: <1991Mar26.152847.5853@athena.mit.edu> Organization: Siemens Nixdorf Informationssysteme AG, Duesseldorf Lines: 20 In article <1991Mar26.152847.5853@athena.mit.edu>, ahodgson@athena.mit.edu (Antony Hodgson) writes: > > Suppose I have a function, void f( Base& b ), and inside f() I want to > make a local copy of whatever b is. Since b could actually be a derived > class.... You need a deep clone mechanism, supported by the object itself. This basically means, the object, and whatever object possibly hidden inside or stored inside the object to be copied, must be able to clone itself and return a pointer to the clone. This is similar to fork(), but some- what more complicated. As far as I remember, ET++ supports deep cloning of complex objects. I don't know, however, how they did it exactly. If you have access to a machine supporting file-names longer than 14 char- acters, you'd best get a copy of ET++ (it's for free). The authors work at the Union Bank of Switzerland. c.u. Christian