Potential problem using "using namespace"

Setting a default namespace can look like a good idea at first since then you don’t have to keep typing “std::” all the time or whatever namespace it is that you use. The problem with this is that with time you will start adding more and more code prevenient from different namespaces, at that point, imagine that there are two functions called “cout” the std one that prints to the console and another one that would do whatever. If you don’t type std:: how is the compiler supposed to know which one you want? That’s is basically the problem with it.

If one uses namespace it can make the coding seem less tedious at first because you don’t need to type std:: over and over. The coding will however need to be more specified between the difference of name spaces, which can make it seem just as complicated, if not more than it would have been with the use of std::. The use of namespace in of itself does not change itself for differing parts of the code, therefore more actually work has to be done for every part to function as it has been intended.

Privacy & Terms