Article View: comp.std.c++
Article #502new[] and constructor arguments
From: Robert Krajewski
Date: Wed, 12 Sep 1990 17:57
Date: Wed, 12 Sep 1990 17:57
18 lines
1296 bytes
1296 bytes
Does anybody else consider the fact that new[] only works with default constructors (i.e., those with no parameters) to be a blemish on the language ? If you spend some time generate a nice simple consistent class, and then discover you need to use new[], you have to then go and implement modification operations that may be have been unneccessary before. There are workarounds, I realize, like writing your own loop and using operator new (size_t, void *). Basically, I don't buy the argument in the bulletted item on page 61 of E&S (section 5.3.3). The compiler can easily generate correct and efficient initialization code for this case where parameters are passed. The only decision to be made is how many times the arguments to a constructor are evaluated in such a context. Robert P. Krajewski Internet: rpk@ai.mit.edu ; Lotus: robert_krajewski.lotus@crd.dnet.lotus.com
Technical Details
Message-ID:
<10647@life.ai.mit.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!ai-lab!rice-chex!rpkShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!ai-lab!rice-chex!rpk From: rpk@rice-chex.ai.mit.edu (Robert Krajewski) Newsgroups: comp.std.c++ Subject: new[] and constructor arguments Message-ID: <10647@life.ai.mit.edu> Date: 12 Sep 90 17:57:01 GMT Sender: news@ai.mit.edu Organization: MIT Artificial Intelligence Laboratory Lines: 18