Risks of using namespace

So to me it sounds like if you use namespace to many times then you start to get to the point of where you are referring to multiple things with the same name. Kind of like referring to multiple Bob’s you won’t know which bob you’re talking about if you just refer to each of them just as Bob.


A namespace is what it looks like. A space that contains several things and that space has a single name. Its like an object , in the same way the Object is a container that contains variables and functions.

Generally speaking a name clash is kinda rare for a namespace because usually libraries come with a unique name, like iostream, boost, unreal etc

A namespace can contain another namespace but if the clash does not happen at the high level , the top namespace, then it will be impossible to happen later on because in order to have a clash later on you will have to have a clash at the top namespace.

Another cool thing you can do with namespaces is rename them , this technique is used by coders to simplify the name of a namespace or give it a more familiar name. The change of the namespace will not affect the definition of the namespace itself so changing its name in your app will not affect any other app or module that use the same namespace.

Namespaces also offer many other tricks and features which are beyond the scope of this beginner course.

Thanks for the reply. I was beginning to think this forum was dead for this udemy class.

its not dead, its undead

we only reply when we get out to hunt for fresh brains

1 Like

Well mine aren’t so fresh, but they are still agile as anyone else. They might be a bit tough as well. I work them hard.

1 Like


Following recommendations of Bjarne Stroustrup(founder of c++) I usually use prefix “std” when writing a header file(which could be used for someone else) but always use “using namespace std” in my cpp files.This is my space and my rules apply.I’m aware of taking some risk.Risk of the names collision is very low. No one wants to give e.g “cout” name to his new variable’s name.

Privacy & Terms