From: horst DOT kraemer AT t-online DOT de (Horst Kraemer) Newsgroups: comp.os.msdos.djgpp Subject: Re: variable declaration in for-header fails?? Date: Thu, 13 Jan 2000 20:13:13 GMT Organization: T-Online Lines: 65 Message-ID: <387e27c9.16119163@news.btx.dtag.de> References: <387d91d5 DOT 333064 AT news DOT netcologne DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news01.btx.dtag.de 947794293 15161 0306239354-0001 000113 20:11:33 X-Complaints-To: abuse AT t-online DOT de X-Sender: 0306239354-0001 AT t-dialin DOT net X-Newsreader: Forte Free Agent 1.11/32.235 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Thu, 13 Jan 2000 10:42:55 GMT, karpfenteich AT gmx DOT de (Peter Karp) wrote: > This first way compiles flawlessly with version 2.03: > #include > using namespace std; > int main() > { > int x; > for(x=1, cout << x , x++ ;x<=100; x++) > cout << ", " << x; > > cout << endl; > > return(0); > } Correct. > ------------ > but fails, when I define the counter inside the loop declaration: > > #include > using namespace std; > int main() > { > for(int x=1, cout << x , x++ ;x<=100; x++) > cout << ", " << x; > > cout << endl; > > return(0); > } > BTW, Borland C++ 3.1 compiles this version without an error, while This is a open lie ;-) Borland C++ 3.1 doesn't compile it for the same reason as GNU C++ doesn't. And of course BCC++ 3.1 doesn't support the syntax and doesn't support 'namespace'. But even after changing this it doesn't compile. int x=1, cout << x , x++ ; is illegal. You cannot separate a declaration and an expression like cout<