"David Rubin" <fu******@warpmail.net> wrote in message
news:CO*******************@twister.nyc.rr.com...
project2.C: In function `int main()':
project2.C:6: `cout' undeclared (first use this function)
project2.C:6: (Each undeclared identifier is reported only once for each
function it appears
Try std::cout and std::endl or 'using namespace std;'
or:
using std::cout;
using std::endl;
I found this
diagnostic a bit confusing too the first time I saw it.
"'cout' undeclared." Exactly the case. How much more specific
could it be? :-)
Before you say e.g. "well the compiler should 'know' it's a
'namespace std' issue, I'll say that no, it cannot (and should not)
make such an assumption. I might want an identifer of my own named
e.g. 'cout', which I have every right to define, in either a 'global',
'file', 'namespace'*, or 'local' scope, and expect no problems until I
explicitly cause a conflict with a 'using' statement which brings
'std::cout' into scope.
(*) except namespace 'std', where the 'user' is not
allowed to define anything.
OP's problem is not an 'ambiguous' error message, but insufficient
background knowledge before using the compiler.
-Mike