scaryfast Posted August 1, 2005 Report Share Posted August 1, 2005 (edited) Hi. When I try compiling the following source using g++: #include <iostream> int main() { cout << "Hello, World\n"; return -1; } I get: hello.cc: In function `int main()': hello.cc:4: error: `cout' undeclared (first use this function) hello.cc:4: error: (Each undeclared identifier is reported only once for each function it appears in.) Can anyone help me fix this? Edited August 1, 2005 by scaryfast Quote Link to comment Share on other sites More sharing options...
scaryfast Posted August 1, 2005 Author Report Share Posted August 1, 2005 I've just figured this out - #include <iostream> using namespace std; int main() { cout << "Hello World From About\n"; } I needed the 'namespace'. How embarrasing. Sorry. Quote Link to comment Share on other sites More sharing options...
steppenwolf1984 Posted August 18, 2005 Report Share Posted August 18, 2005 Dont feel so bad, that undeclared cout keep me going for weeks! I was using a rather useful tutorial.....when in doubt, learn python i always say.... :P Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.