Alex,
Foo(i ) means 'i' is declared a variable of type Foo.
but 'i' is already defined and C++ do now allow redeclaration.
Thanks
Avinash
"Alex Vinokur" <alexvn@bigfoot.com> wrote in message news:<bkrehl$4htlf$1@ID-79865.news.uni-berlin.de>...[color=blue]
> Hi,
>
> What is wrong with this code?
>
> ====== C++ code : File t.cpp : BEGIN ======
> #include <iostream>
> using namespace std;
>
> struct Foo
> {
> Foo (int n) { cout << n << endl; }
> };
>
> int main ()
> {
> int i = 100; // Line#11
>
> Foo (i); // Line#13 : Compilation error
> Foo f (i); // Compiled with no errors
>
> Foo (200); // Compiled with no errors
> Foo (int(300)); // Compiled with no errors
>
> return 0;
> }
> ====== C++ code : File t.cpp : END ========
>
>
> ====== Compilation : BEGIN ======
>
> $ g++ -v
> [--omitted--]
> gcc version 3.3.1 (cygming special)
>
> $ g++ t.cpp
>
> t.cpp: In function `int main()':
> t.cpp:13: error: conflicting types for `Foo i'
> t.cpp:11: error: previous declaration as `int i'
>
> ====== Compilation : END ========
>
>
> =====================================
> Alex Vinokur
> mailto:alexvn@connect.to
>
http://mathforum.org/library/view/10978.html
> =====================================[/color]