Mail Archives: djgpp/2000/01/13/09:30:30
From: | karpfenteich AT gmx DOT de (Peter Karp)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | variable declaration in for-header fails??
|
Date: | Thu, 13 Jan 2000 10:42:55 GMT
|
Lines: | 59
|
Distribution: | world
|
Message-ID: | <387d91d5.333064@news.netcologne.de>
|
NNTP-Posting-Host: | dial-ra-nc1-100.netcologne.de
|
X-Trace: | news.netcologne.de 947760030 21218 195.14.244.100 (13 Jan 2000 10:40:30 GMT)
|
X-Complaints-To: | usenet AT news DOT netcologne DOT de
|
NNTP-Posting-Date: | 13 Jan 2000 10:40:30 GMT
|
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
|
Hi :-)
I have a little question, why DJGPP can't compile a program where I've
defined a counter in the for loop (which is better, as the counter is
"more local" then, right?).
This first way compiles flawlessly with version 2.03:
#include <iostream>
using namespace std;
int main()
{
int x;
for(x=1, cout << x , x++ ;x<=100; x++)
cout << ", " << x;
cout << endl;
return(0);
}
------------
but fails, when I define the counter inside the loop declaration:
#include <iostream>
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
DJGPP gives the following error message:
E:\aa\cpp>gxx test.cpp
test.cpp: In function `int main()':
test.cpp:7: parse error before `<'
test.cpp:8: invalid operands `int' and `const char[3]' to binary
`operator <<'
test.cpp:10: warning: name lookup of `cout' changed
d:/progra~1/djgpp/lang/cxx/iostream.h:250: warning: matches this
`cout' under
current ANSI rules
test.cpp:7: warning: matches this `cout' under old rules
Greetings from Cologne
Peter
E-Mail: karpfenteich AT gmx DOT de
- Raw text -