Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!motcsd!hpda!hpcuhb!hpcllla!hpclisp!hpclscu!shankar From: shankar@hpclscu.HP.COM (Shankar Unni) Newsgroups: comp.lang.c++ Subject: Re: Call of constructors by vectors Message-ID: <1000012@hpclscu.HP.COM> Date: 12 Jun 89 19:23:36 GMT References: <1904@mas1.UUCP> Organization: Hewlett-Packard Calif. Language Lab Lines: 28 > A better question is why does: > SomeClass x[100]; > with: > inline SomeClass::SomeClass(){} > cause 100 invocations of this do-nothing "initializer" whereas x1 does not > cause even 1 invocation of the do-nothing "initializer". Lazy code generation... No, I take that back. This is a solvable problem, but I suppose that the ROI for doing it the most efficient way was not seen as making it worthwhile to do. Who knows.. In general, it's easy to do the trivial case of the null constructor (I mean a constructor with an empty body). If the constructor has even 1 statement, it becomes pretty hard. A better solution would have been an array constructor syntax. Maybe something like: SomeClass::SomeClass[int count]() { ... } Naah! :-) (Parsing C++ is already a pain in the ***; no need to make it any worse). But seriously, it would address this problem. Only one function is called with a pointer to the array and a number of elements, and whatever other parameters the user specifies. ---- Shankar.