0
what is namespace std used in programs??
3 odpowiedzi
+ 1
An answer of mine on a very similar question:
The iostream header puts the classes and other elements in a namespace called "std" which also includes all other classes, functions etc. from the standard library (but those are put in separate headers).
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" is a homonym as it 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.
0
prevent name collision when your using many libraries
0
name collision ?? can u elaborate it plzz