Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Parentheses after new Message-ID: <420@taumet.com> Date: 24 Aug 90 16:32:28 GMT References: <1619@m1.cs.man.ac.uk> Distribution: comp Organization: Taumetric Corporation, San Diego Lines: 31 jk@cs.man.ac.uk (John Kewley ICL) writes: >The following fails to compile on both G++ and Sun C++. Could you tell me >why the brackets around new's argument is illegal.... >class test >{ >public: > test(int eek); > test(); >}; >int main() >{ > test* thattest= new (test); > test* thistest= new (test(1)); >} The keyword _new_ may be optionally followed by a placement expresion-list in parens, followed by either a type-name in parens or a new-type-name not in parens. If there is no placement, _new_ must be followed by a new-type-name or by a type-name in parens. Finally, an initializer-list in parens may be tacked onto any of these. So the outer-level parens in a _new_ clause are not part of any expression, but part of the _new_ syntax to determine which form is being used. The examples you have do not fit any of the syntax productions. -- Steve Clamage, TauMetric Corp, steve@taumet.com -- Steve Clamage, TauMetric Corp, steve@taumet.com