Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 29
    IMO it is better to just get used to prefixing the std namespace to symbols rather than using using at all. So I always write std::cout or std::string now because that's what I call them now. I would never just write cout. Commented Dec 5, 2009 at 11:41
  • 5
    While this is very true for std, I've personally found this much less important when you're dealing with smaller libraries. Often you can just use using namespace FooBario;, particularly if you're using a considerable number of types from a library. Commented Oct 30, 2010 at 5:13
  • 4
    @jkerian, I see your point, but I disagree because name collisions are (in my mind) more likely to come from precisely such small libraries. Most people are careful not to name classes/functions the same as those in STL. That said, I agree that using namespace X; should be avoided in header files if possible. Commented May 28, 2011 at 7:22
  • 15
    @LexFridman "Most people are careful not to name classes/functions the same as those in STL" - that is SO NOT TRUE. For example if I were to write some very specialized I/O code for some weird hardware, I would never, ever, use anything else than mylibrary::endl for representing my very own special newline sequence. I mean, why invent names? Commented Oct 24, 2011 at 12:46
  • My compiler still won't recognize the namespace, even though I want to explicitly specify it and I include the file where it is declared. Commented Nov 13, 2015 at 0:21