[net.lang.c++] Declarations in statements -- a question.

stephen@comp.lancs.ac.uk (Stephen J. Muir) (08/17/86)

Can anybody explain why the following fails to compile:

main ()
{	if (int i = 5)
		/* do something */;
}

when the following succeeds:

main ()
{	for (int i = 5; i; )
		/* do something */;
}

C++ version 1.1, BSD 4.2, DEC VAX-11/750.
-- 
EMAIL:	stephen@comp.lancs.ac.uk	| Post: University of Lancaster,
UUCP:	...!mcvax!ukc!dcl-cs!stephen	|	Department of Computing,
Phone:	+44 524 65201 Ext. 4120		|	Bailrigg, Lancaster, UK.
Project:Alvey ECLIPSE Distribution	|	LA1 4YR