Path: utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: The type yielded by "new T[expression]" Message-ID: <10605@alice.UUCP> Date: 21 Mar 90 04:23:52 GMT References: <26068361.27247@paris.ics.uci.edu> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 30 In article <26068361.27247@paris.ics.uci.edu>, rfg@paris.ics.uci.edu (Ronald Guilmette) writes: > I believe that there exists a ghastly violation of strong typing rules > currently built into the C++ language. I'd like somebody to explain > this to me and defend it (if possible). Not particularly ghastly, but rather a minor convenience that is well described in the manual. > Now the question I'm concerned about is: "What is the type of the value > yielded by: > new T[size]; The type is `pointer to T' for any `new' statement with this syntax. > Currently (it seems) the value yielded by an "array new" operation like > this is treated as being of type "pointer-to-T". This seems highly > nonsensical to me. It would make far more sense if the type of value > yielded were "pointer-to-array-of-T" when the "new" invocation includes > a (square-bracketed) size expression. Impossible, because `size' doesn't need to be a constant. If you want a pointer to array of, say, 17 T, you can write new T[17][1] which will get you exactly that. -- --Andrew Koenig ark@europa.att.com