I've been coding for many years as a hobby and I'm now studying computer science which is a great way to answer the "why"s as well as the "how"s of the programming world. I've seen many great code examples across multiple message boards including this one and I'm wondering why some people would rather add "std::" to every single line of code rather than just adding "using namespace std;" once and never having to worry about it ever again. I understand some projects involve multiple namespaces, but what about the ones that only use "std::"? I hope someone might be able to shed some light on this, and I'm sorry if this comes off as a dumb question. Thanks!
Asked
Active
Viewed 104 times
0
-
1just yesterday you could see on reasons 'live' on SO: http://stackoverflow.com/questions/39423474/socket-binding-wont-return-an-int – stijn Sep 11 '16 at 08:01
-
And another one 2 days ago :-) http://stackoverflow.com/questions/39394523/moving-a-class-derived-from-istream – Bo Persson Sep 11 '16 at 08:14
1 Answers
0
Well, if it is not a matter of coding style, people including myself here usually goes to "std::" to avoid name collisions that may happen when you start "using" a few namespaces in your code. By specifying the entire scope (ex "std::string") of a type you are reducing the name collision risk to pretty much zero.

WelsonJR
- 299
- 3
- 5