+ 6

Why do some people use std:: everywhere instead of using namespace std?

Seen mostly in stackoverflow.com and other fourums. It is both tiring to write code and also read someone's code that way but still some do it, why? Are there cases where using namespace std wont work?

8th Feb 2017, 6:01 AM
Vishal++
Vishal++ - avatar
2 ответов
+ 6
'using namespace' is considered bad practice. If you use many classes and/or libraries in a program some of the functions and other stuff might share the same or similar names. By just using 'using namespace' at the top of your program you'll have a hard time figuring out what functions are from what class/library if you're reading the code (it might even use the wrong function somewhere!). You probably won't run into problems anytime soon, but most programmer will just go with the std:: everywhere, even if it might be more to type.
8th Feb 2017, 6:37 AM
Robobrine
Robobrine - avatar
+ 5
using namespace std; is good for learning basics but like @Robobrine said is considered as bad practice.
26th Feb 2017, 2:07 PM
Tomasz Basmann
Tomasz Basmann - avatar