Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!snorkelwacker!ai-lab!rpk From: rpk@wheaties.ai.mit.edu (Robert Krajewski) Newsgroups: comp.lang.c++ Subject: Re: calling a constructor Message-ID: <9713@rice-chex.ai.mit.edu> Date: 5 Aug 90 19:44:09 GMT References: <1990Aug1.145814.16140@dg-rtp.dg.com> Reply-To: rpk@rice-chex.ai.mit.edu (Robert Krajewski) Organization: MIT Artificial Intelligence Laboratory Lines: 25 I don't really fancy myself a C++ expert, but doesn't the standard C++ library provide an alternate (overloaded) form of new: void *operator new ( long size, void *memAddress ); that effectively invokes the constructor properly ? (This is found in the _C++ Primer_, page 164, but should the long there actually be a size_t ?) Suppose IntArray is a class with a constructor that takes an int for an argument: #include char buf [ sizeof(IntArray) ]; // Normal new use IntArray *pa = new IntArray(10); // Give new a place IntArray *pbuf = new (buf) IntArray( 10 ); -- Robert P. Krajewski Internet: rpk@ai.mit.edu ; Lotus: robert_krajewski.lotus@crd.dnet.lotus.com