Another "risk of using namespace" post

Hi, so here’s my shot at describing the risk of using namespace. By itself, a namespace is a good thing. It allows you to scope all your function, constants and global variables to your program, allowing it to safely interact with other libraries which have their own functions and variables and constants. Since it is namespaced, you are now able to write your own functions without having to worry about overriding functionality or using incorrect values.

Just be sure to just use your own namespace, if you start writing “using namespace not_mine” just to save yourselfa few key strokes (ex: std::), you might end up overriding things that will keep bringing up bugs.

Personally, I like that C++ has namespaces and that you have to write “std::”. It makes it that much clear to understand where things come from and you as a programmer are more conscious of what dependencies you are actually using.

Privacy & Terms