Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!jarthur!ucivax!orion.oac.uci.edu!ucsd!ames!elan!tom From: tom@elan.Elan.COM (Thomas Smith) Newsgroups: comp.lang.c++ Subject: Re: Copy constructors Message-ID: <912@elan.Elan.COM> Date: 9 Jan 91 21:15:58 GMT References: Distribution: comp Organization: Elan Computer Group, Inc., Mountain View, CA Lines: 25 From article , by cimshop!davidm@uunet.UU.NET (David S. Masterson): > [ copy constructor definition deleted ] > How is memberwise assignment or initialization meant to handle virtual > functions and the hidden virtual function table pointer? Is the Vtabptr left > alone in this? > > The reason I ask this has to do with transmitting of objects from one process > to another. Assuming that type of the object is known after transmission, it > should be possible to cast the transmission buffer to that type and copy > construct a true object of that type using the buffer as input. Does this > make sense with respect to section 12.8 in the ARM? Rather than doing the cast in your above example, you might try overloading the 'new' operator. Define a new operator for your specific class that takes an additional pointer as a parameter. Your 'new' operator function would then take the passed pointer and use it in place of the usual free store. This will set up the virtual function table for you. There are examples of this technique in most manuals that I've seen - it is also used for implementing class-specific memory management. Hope this helps, Thomas Smith Elan Computer Group, Inc. (415) 964-2200 tom@elan.com, ...!{ames, uunet, hplabs}!elan!tom