Namespace and its Risks

I see many great explanations regarding why “using namespace std;” can pose problems. Here’s my take on the problem.

Namespaces are essentially containers that hold groupings of identifiers and symbols. When I type “using namespace std;”, I’m telling the compiler that it should reference that namespace when I type anything that matches. However, when you’re writing a large program, you might use different libraries to access different features. These libraries might have similar namespaces, so when you want an identifier to do a certain command, the compiler might do another.

It’s like naming all your children “John” and trying to call one of them. Who are you trying to call?

1 Like