Jump to content
  • Advertisement

Archived

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

xidis

Is it the compiler or me?

This topic is 5321 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
Thanks guys...

using std::cout works fine

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

Share this post


Link to post
Share on other sites
#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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!