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:al****@connect.to
http://mathforum.org/library/view/10978.html
=====================================