+ 1
Why do we need to add namespace tag
4 Answers
+ 5
In academic environments, it can frequently be the case where many are condemned for not using 'using namespace std'. Lecturers, especially those who lack experience in actual software development, want an easy job marking the papers. Were we taught about it's purpose and why 'using namespace std' is needed, or how it works? No. We weren't even taught what namespaces are.
It is simply a bad practice to freely use something when you don't understand how it works.
What I see essential is for namespaces to be taught to beginners with sufficient explanation, and not forced upon them. The recent disagreements I had with the system got me trying to not use it (which is a royal pain once you've stuck with it for some time, all the more reason to eliminate blind practice of 'using namespace std').
+ 4
Because
Namespaces allow us to group named entities that otherwise would haveglobal scope into narrower scopes, giving them namespace scope. This allows organizing the elements of programs into different logical scopes referred to by names. Namespace is a feature added in C++ and not present in C.
+ 2
Source of Mr. White's response:
https://www.geeksforgeeks.org/namespace-in-c/
0
It is also good to know that namespaces will get you in trouble if the same function is in two code pacakges. That is why in larger projects, you normally don't use namespaces and instead call it directly std::cin.