Declaring our namespace with using namespace std provides scope to our identifiers, improving organization when our code becomes more complex and reducing typing.
Bad! As your code will become more and more complex, using namespace std increases the chances of name clashes. Furthermore, when you see std::something, you know it's from the standard library and you know what it does (well... in many cases you will look for it on cppreference XD). When you simply see something, you may wonder what it is.
Never use using namespace in header files (std being the worst namespace to use).
If you want to use that in source files, be cautious. Don't forget that you can do using std::cout if you are lazy enough and want to save 5 characters.
If you have a modern IDE with shortcuts for templates, you can ease your writing. For instance, in CLion, I have a template so that autocompletion expands cout to std::cout << | << '\n'; with | being my cursor after expansion :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Bad! As your code will become more and more complex,
using namespace std
increases the chances of name clashes. Furthermore, when you seestd::something
, you know it's from the standard library and you know what it does (well... in many cases you will look for it on cppreference XD). When you simply seesomething
, you may wonder what it is.Never use
using namespace
in header files (std
being the worst namespace to use).If you want to use that in source files, be cautious. Don't forget that you can do
using std::cout
if you are lazy enough and want to save 5 characters.If you have a modern IDE with shortcuts for templates, you can ease your writing. For instance, in CLion, I have a template so that autocompletion expands cout to
std::cout << | << '\n';
with | being my cursor after expansion :)