using namespace std;
is bad practice for a variety of reasons, all of which you can find on google. One of those reasons is that it completely negates the entire point of namespaces.From Stack Overflow -- consider this: You are using two libraries called Foo and Bar: Everything works fine, you can call Blah() from Foo and Quux() from Bar without problems. But one day you upgrade to a new version of Foo 2.0, which now offers a function called Quux(). Now you've got a conflict: Both Foo 2.0 and Bar import Quux() into your global namespace. This is going to take some effort to fix, especially if the function parameters happen to match. If you have used foo::Blah() and bar::Quux() then the introduction of foo::Quux() would have been a non-event. Library Foo 2.0 could introduce a function, Quux(), that is an unambiguously better match for some of your calls to Quux() than the bar::Quux() your code called for years. Then your code still compiles, but it silently calls the wrong function and does god-knows-what. That's about as bad as things can get. Keep in mind that the std namespace has tons of identifiers, many of which are very common ones (think list, sort, string, iterator, etc.) which are very likely to appear in other code, too. |