jk@cs.man.ac.uk (John Kewley ICL) (08/23/90)
The following fails to compile on both G++ and Sun C++. Could you tell me
why the brackets around new's argument is illegal.
I thought it would be a nice way of grouping the expression for a
new statement (function?):
class test
{
public:
int eekeek;
test(int eek) {eekeek= eek;}
test() {eekeek= 4;}
};
int main()
{
test* thattest= new (test);
test* thistest= new (test(1));
return(0);
}
--
J.K.
John M. Kewley, ICL, Wenlock Way, West Gorton, Manchester. M12 5DR
Tel: (+44) 61 223 1301 X2138 Email: jk@r6.cs.man.ac.uk / jk@nw.stl.stc.co.uksteve@taumet.com (Stephen Clamage) (08/24/90)
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