This came up on another thread, rather that "pollute" that thread with a side issue, I'll start a new thread.
The issue is; Is it better to just to individually declare the
members of std to be used in a program, or is the global declaration "using namespace std" being unjustly maligned as a "global polluter".
For an authoritative answer, I went to the master himself, Bjarne Stroustrup, "The C++ programming Language" special edition, printed Jan 2006.
While he generally frowns upon the use, or more precisely,overuse of global declarations, due to the possibility of ambiguity, he does make a distinction between custom namespaces and the standard library.
The problem comes up if you start naming global variables associated with a namespace.
Morerover, unused names are NOT consiered errors
"When libraries declaring many names are made accessable thorough using-directives, it is a signifcant advantage that clases of unused names are not considered errors" (page 847).
All in all , it seems poor ol' using namespace std is just misunderstood and benign if used properly.
Who the heck want's to write std:: in front over everthing if you don't have to? It is however, recommended to do so with custom classes ie;
That is the distinction!
For very small programs like one might write in college or HS I see nothing wrong with "using namespace std". But in larger commercial programs that probably should not be used due to many of the reasons you and others in the other thread have stated. A lot depends on the program you are writing and on your own personal preference. I hate seeing std:: in front of everything too and will either code "using namespace std" or "using std::cin" etc. at the top of the *.cpp file.
If the program is using more than one namespace and there is a possibility that the same symbol name is defined in each namespace, then there is no choice but to put the namespace in front of the symbol name each time it is used to avoid ambiguity.