Archived

This topic is now archived and is closed to further replies.

xidis

Is it the compiler or me?

Recommended Posts

xidis    127
I came across an issue with my compiler or me, i dont know which, when i was learning about the using namespace command. I had the followring code, one set uses a namespace declaration and the other set uses a namespace directive. The namespace directive causes errors in the compiler. #include <iostream> int main() { using namespace std; cout << "Message..."; return 0; } and #include <iostream> int main() { using namespace std::cout; cout << "Message..."; return 0; } The above gives me errors. I am using the Bloodshed C++ Compiler. Is the compiler wrong, or is it me?

Share this post


Link to post
Share on other sites
Hysteria    122
#include <iostream>
int main()
{
using namespace std;
cout << "Message...";
return 0;
}

into

#include <iostream>
using namespace std;

int main()
{
cout << "Message...";
return 0;
}

Share this post


Link to post
Share on other sites
Zahlman    1682
quote:
Original post by xidis
Thanks guys...

using std::cout works fine

Now im just wondering why the book told me something different...


Code printed in books - especially for C++ - is notorious for being wrong.

Share this post


Link to post
Share on other sites