0
What is a namespace??
2 Answers
0
namespace is created by developers because they were facing difficulty in remembering function names. we can use same variable name in different namespaces.
"std" namespace is already defined in which many operators like cin and cout exists. So you need to include it it your program.
0
To paste my answer from June on this reoccurring question (I hope it gives insight to the concept of namespaces instead of just giving technical examples):
Namespaces are a way of preventing so called "name collision", i.e. multiple *definition* (not necessarily declaration) of the same symbol.
This can occur in projects that are bigger than these presented here at SoloLearn C++ as homonyms become more likely to occur. A term is a homonym if this term is used in different meanings. It's the opposite of synonyms which denote different words for the same meaning.
An example: the word "bow" can mean the thing you use to play a violin or a (medieval) weapon. You could want to write a, let's say, role-playing game set in the middle ages.
Then you might want to model in your code the weapon *and* the music utility. In order to distinguish between the weapon and the music utility without changing the name of the classes, you put one bow class in the namespace music and the other in the namespace weapon.
Or getting back to language more generally: you determine the context of a term in order to prevent ambiguity.



