Mail Archives: djgpp/2000/01/13/17:06:46
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 <iostream>
> 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 <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
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 <iostream> 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<<x by a comma.
You can use _either_ a declaration like int x=1; _or_ an expression
like
x=1,...,....,...;
but you can't have both.
Regards
Horst
- Raw text -