The risk of using Namespace

The problem with using namespace is that if a namespace is defined in another class it can cause problems when you call on the names space as the system will be confused on which namespace you are calling on

Actually, a namespace is dangerous because of functions defined. If you have two functions called “HelloWorld” in two different namespaces that you are “using”, then it becomes dangerous. The compiler will not know which function to use so problems will emerge. It really doesn’t matter if you are using the same namespace elsewhere though, as the functions in that namespace elsewhere will be added to the namespace.

I am going to assume that you are new to programming in C++ or possibly programming in general. I just wanted to help clarify the danger of using a namespace. It has to due with having multiple functions of the same name declared, not multiple namespaces of the same name declared.

I hope this helped your understanding a little bit!

Privacy & Terms