cross-posted from: https://lemmy.ml/post/70930

I am learning C++ and in my book using namespace std is written in every program. I understand that std::cout <<"hello"; can be simply written as cout << "hello"; by using namespace std.

Why?

    • freely
      link
      fedilink
      arrow-up
      3
      ·
      3 years ago

      I don’t blame beginners for using it. So many starter guides show using namespace std; without even explaining it or its pitfalls.

      All I can say is to get used to writting std::
      It’s not really that much work, and makes it more obvious where some calls are coming from for any readers of your code.