Hello I am fairly new to the c++ environment and I tried writing a simple Hello world application (see code block) however I got a error message saying that cout was undeclared.... Please help! Thanks in advance!
1 2 3 4 5 6 7 8
#include <iostream>
usingnamespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
Your compiler could be corrupted or the settings could be off. Try restarting the IDE, and if that doesn't work possibly re-installing it. Troubleshooting it could be worth it if the IDE takes a long time to download. I had a problem like that with Code::Blocks and a re-install fixed it.
I got a error message saying that cout was undeclared
Since it's isolated to cout, perhaps your include directories aren't configured properly. If your linker can't find <iostream> it won't know what std is, resulting an undefined cout. I don't think it's the compiler as it's one of the linkers jobs to link the files together( Linker is self-explanatory ). Double-check your directory configurations.
I could be wrong. It could be your IDE, or your compiler could be a bit thick and not realize that cout is a valid statement within the code posted.
Isn't it the preprocessor that includes headers, and the compiler that compiles all the code in the CPP? I don't see what the linker has to do with preprocessor directives, or why he wouldn't get an error if it couldn't find <iostream>...